use of org.apache.carbondata.core.scan.filter.intf.FilterOptimizer in project carbondata by apache.
the class RangeFilterProcessorTest method createFilterTree.
@Test
public void createFilterTree() {
Expression inputFilter;
boolean result = false;
ColumnExpression cola = new ColumnExpression("a", DataTypes.STRING);
cola.setDimension(true);
ColumnSchema empColumnSchema = new ColumnSchema();
empColumnSchema.setColumnName("empNameCol");
empColumnSchema.setColumnUniqueId("empNameCol");
empColumnSchema.setDimensionColumn(true);
empColumnSchema.setEncodingList(Arrays.asList(Encoding.DICTIONARY));
empColumnSchema.setDataType(DataTypes.STRING);
CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0);
cola.setDimension(empDimension);
Expression greaterThan = new GreaterThanEqualToExpression(cola, new LiteralExpression("11", DataTypes.STRING));
ColumnExpression colb = new ColumnExpression("a", DataTypes.STRING);
colb.setDimension(true);
colb.setDimension(empDimension);
Expression lessThan = new LessThanEqualToExpression(colb, new LiteralExpression("20", DataTypes.STRING));
inputFilter = new AndExpression(greaterThan, lessThan);
Expression output = new AndExpression(new RangeExpression(new GreaterThanEqualToExpression(new ColumnExpression("a", DataTypes.STRING), new LiteralExpression("11", DataTypes.STRING)), new LessThanEqualToExpression(new ColumnExpression("a", DataTypes.STRING), new LiteralExpression("20", DataTypes.STRING))), new TrueExpression(null));
FilterOptimizer rangeFilterOptimizer = new RangeFilterOptmizer(inputFilter);
rangeFilterOptimizer.optimizeFilter();
result = checkBothTrees(inputFilter, output);
Assert.assertTrue(result);
}
Aggregations