use of org.apache.calcite.linq4j.tree.OptimizeShuttle in project calcite by apache.
the class BlockBuilderTest method testTestCustomOptimizer.
@Test
public void testTestCustomOptimizer() {
BlockBuilder b = new BlockBuilder() {
@Override
protected Shuttle createOptimizeShuttle() {
return new OptimizeShuttle() {
@Override
public Expression visit(BinaryExpression binary, Expression expression0, Expression expression1) {
if (binary.getNodeType() == ExpressionType.Add && ONE.equals(expression0) && TWO.equals(expression1)) {
return FOUR;
}
return super.visit(binary, expression0, expression1);
}
};
}
};
b.add(Expressions.return_(null, Expressions.add(ONE, TWO)));
assertEquals("{\n return 4;\n}\n", b.toBlock().toString());
}
Aggregations