QueryFilter f1 = subFilters.get(0);
QueryFilter f2 = subFilters.get(1);
// f1: ((c1+c2)/c3*c4) > (c5/c6+year(c7))
ScalarFunctionColumn col1 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(new SimpleColumn("c1"),
new SimpleColumn("c2")), Sum.getInstance());
ScalarFunctionColumn col2 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(col1, new SimpleColumn("c3")),
Quotient.getInstance());
ScalarFunctionColumn col3 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(col2, new SimpleColumn("c4")),
Product.getInstance());
ScalarFunctionColumn col4 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(new SimpleColumn("c5"),
new SimpleColumn("c6")), Quotient.getInstance());
ScalarFunctionColumn col5 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(col4,
new ScalarFunctionColumn(Lists.<AbstractColumn>newArrayList(
new SimpleColumn("c7")), TimeComponentExtractor.getInstance(
TimeComponentExtractor.TimeComponent.YEAR))),
Sum.getInstance());
assertTrue(f1 instanceof ColumnColumnFilter);
ColumnColumnFilter ccf = (ColumnColumnFilter) f1;
assertEquals(col3, ccf.getFirstColumn());
assertEquals(col5, ccf.getSecondColumn());
// f2: (c8+c9=0 or c10<>c11)
assertTrue(f2 instanceof CompoundFilter);
CompoundFilter cf = (CompoundFilter) f2;
assertEquals(CompoundFilter.LogicalOperator.OR, cf.getOperator());
subFilters = cf.getSubFilters();
assertEquals(2, subFilters.size());
assertTrue(subFilters.get(0) instanceof ColumnValueFilter);
assertTrue(subFilters.get(1) instanceof ColumnColumnFilter);
assertEquals(new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(new SimpleColumn("c8"),
new SimpleColumn("c9")), Sum.getInstance()),
((ColumnValueFilter) subFilters.get(0)).getColumn());
assertEquals(new NumberValue(0),
((ColumnValueFilter) subFilters.get(0)).getValue());
assertEquals(Sets.newHashSet("c10", "c11"),
subFilters.get(1).getAllColumnIds());