@Test
public void testMaterializingLateboundTree(final @Injectable RecordBatch batch) throws SchemaChangeException {
new NonStrictExpectations() {
{
batch.getValueVectorId(new FieldReference("test", ExpressionPosition.UNKNOWN));
result = new TypedFieldId(Types.required(MinorType.BIT), -4);
batch.getValueVectorId(new FieldReference("test1", ExpressionPosition.UNKNOWN));
result = new TypedFieldId(Types.required(MinorType.BIGINT), -5);
}
};
ErrorCollector ec = new ErrorCollectorImpl();
LogicalExpression expr = new IfExpression.Builder()
.addCondition(
new IfExpression.IfCondition( //
new FieldReference("test", ExpressionPosition.UNKNOWN), //
new IfExpression.Builder()
//
.addCondition( //
new IfExpression.IfCondition(
//
new ValueExpressions.BooleanExpression("true", ExpressionPosition.UNKNOWN),
new FieldReference("test1", ExpressionPosition.UNKNOWN)))
.setElse(new ValueExpressions.LongExpression(1L, ExpressionPosition.UNKNOWN)).build()) //
) //
.setElse(new ValueExpressions.LongExpression(1L, ExpressionPosition.UNKNOWN)).build();
LogicalExpression newExpr = ExpressionTreeMaterializer.materialize(expr, batch, ec);
assertTrue(newExpr instanceof IfExpression);