use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class RangeFilterProcessorTest method createFilterTree_flavor1.
@Test
public void createFilterTree_flavor1() {
// Build 3rd BTree a >= '11' and a > '12' and a <= '20' and a <= '15'
Expression inputFilter;
boolean result = false;
ColumnSchema empColumnSchema = new ColumnSchema();
empColumnSchema.setColumnName("a");
empColumnSchema.setColumnUniqueId("a");
empColumnSchema.setDimensionColumn(true);
empColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY));
empColumnSchema.setDataType(DataType.STRING);
CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0);
ColumnExpression cola1 = new ColumnExpression("a", DataType.STRING);
cola1.setDimension(true);
cola1.setDimension(empDimension);
ColumnExpression cola2 = new ColumnExpression("a", DataType.STRING);
cola2.setDimension(true);
cola2.setDimension(empDimension);
ColumnExpression cola3 = new ColumnExpression("a", DataType.STRING);
cola3.setDimension(true);
cola3.setDimension(empDimension);
ColumnExpression cola4 = new ColumnExpression("a", DataType.STRING);
cola4.setDimension(true);
cola4.setDimension(empDimension);
Expression lessThan1 = new LessThanEqualToExpression(cola1, new LiteralExpression("15", DataType.STRING));
Expression lessThan2 = new LessThanEqualToExpression(cola2, new LiteralExpression("20", DataType.STRING));
Expression greaterThan1 = new GreaterThanExpression(cola3, new LiteralExpression("12", DataType.STRING));
Expression greaterThan2 = new GreaterThanEqualToExpression(cola4, new LiteralExpression("11", DataType.STRING));
Expression And1 = new AndExpression(new NotEqualsExpression(null, null), greaterThan2);
Expression And2 = new AndExpression(And1, greaterThan1);
Expression And3 = new AndExpression(And2, lessThan2);
inputFilter = new AndExpression(And3, lessThan1);
// Build The output
ColumnExpression colb1 = new ColumnExpression("a", DataType.STRING);
cola1.setDimension(true);
cola1.setDimension(empDimension);
ColumnExpression colb2 = new ColumnExpression("a", DataType.STRING);
cola2.setDimension(true);
cola2.setDimension(empDimension);
Expression greaterThanb1 = new GreaterThanExpression(cola3, new LiteralExpression("12", DataType.STRING));
Expression lessThanb1 = new LessThanEqualToExpression(cola1, new LiteralExpression("15", DataType.STRING));
Expression Andb1 = new AndExpression(new NotEqualsExpression(null, null), new TrueExpression(null));
Expression Andb2 = new AndExpression(Andb1, new RangeExpression(greaterThanb1, lessThanb1));
Expression Andb3 = new AndExpression(Andb2, new TrueExpression(null));
FilterOptimizer rangeFilterOptimizer = new RangeFilterOptmizer(new FilterOptimizerBasic(), inputFilter);
rangeFilterOptimizer.optimizeFilter();
result = checkBothTrees(inputFilter, new AndExpression(Andb3, new TrueExpression(null)));
// no change
Assert.assertTrue(result);
}
Aggregations