use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class FilterUtilTest method testGetFilterListForAllMembersRS.
@Test
public void testGetFilterListForAllMembersRS() throws Exception {
Expression expression = new ColumnExpression("IMEI", DataType.STRING);
ColumnExpression columnExpression = new ColumnExpression("IMEI", DataType.STRING);
String defaultValues = "test";
int defaultSurrogate = 1;
boolean isIncludeFilter = true;
int ordinal = 1;
ColumnSchema dimColumn = new ColumnSchema();
dimColumn.setColumnar(true);
dimColumn.setColumnName("IMEI");
dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
dimColumn.setDataType(DataType.STRING);
dimColumn.setDimensionColumn(true);
final CarbonColumn carbonColumn = new CarbonColumn(dimColumn, ordinal, -1);
new MockUp<ColumnExpression>() {
@Mock
public CarbonColumn getCarbonColumn() {
return carbonColumn;
}
};
new MockUp<RowImpl>() {
@Mock
public Object getVal(int index) {
return "test";
}
};
assertTrue(FilterUtil.getFilterListForAllMembersRS(expression, columnExpression, defaultValues, defaultSurrogate, isIncludeFilter) instanceof DimColumnFilterInfo);
}
use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class FilterUtilTest method testCheckIfRightExpressionRequireEvaluation.
@Test
public void testCheckIfRightExpressionRequireEvaluation() {
Expression expression = new ColumnExpression("test", DataType.STRING);
boolean result = FilterUtil.checkIfRightExpressionRequireEvaluation(expression);
assertTrue(result);
}
use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class FilterUtilTest method testGetFilterListForAllMembersRSWithDefaultValuesEqualsToNull.
@Test
public void testGetFilterListForAllMembersRSWithDefaultValuesEqualsToNull() throws Exception {
Expression expression = new ColumnExpression("IMEI", DataType.STRING);
ColumnExpression columnExpression = new ColumnExpression("IMEI", DataType.STRING);
String defaultValues = CarbonCommonConstants.MEMBER_DEFAULT_VAL;
int defaultSurrogate = 1;
boolean isIncludeFilter = true;
int ordinal = 1;
ColumnSchema dimColumn = new ColumnSchema();
dimColumn.setColumnar(true);
dimColumn.setColumnName("IMEI");
dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
dimColumn.setDataType(DataType.STRING);
dimColumn.setDimensionColumn(true);
final CarbonColumn carbonColumn = new CarbonColumn(dimColumn, ordinal, -1);
new MockUp<ColumnExpression>() {
@Mock
public CarbonColumn getCarbonColumn() {
return carbonColumn;
}
};
new MockUp<RowImpl>() {
@Mock
public Object getVal(int index) {
return "test";
}
};
assertTrue(FilterUtil.getFilterListForAllMembersRS(expression, columnExpression, defaultValues, defaultSurrogate, isIncludeFilter) instanceof DimColumnFilterInfo);
}
use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class QueryUtil method getAllFilterDimensions.
public static void getAllFilterDimensions(FilterResolverIntf filterResolverTree, Set<CarbonDimension> filterDimensions, Set<CarbonMeasure> filterMeasure) {
if (null == filterResolverTree) {
return;
}
List<ColumnExpression> dimensionResolvedInfos = new ArrayList<ColumnExpression>();
Expression filterExpression = filterResolverTree.getFilterExpression();
addColumnDimensions(filterExpression, filterDimensions, filterMeasure);
for (ColumnExpression info : dimensionResolvedInfos) {
if (info.isDimension() && info.getDimension().getNumberOfChild() > 0) {
filterDimensions.add(info.getDimension());
}
}
}
use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class RangeFilterProcessorTest method createFilterTree.
@Test
public void createFilterTree() {
Expression inputFilter;
boolean result = false;
ColumnExpression cola = new ColumnExpression("a", DataType.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(DataType.STRING);
CarbonDimension empDimension = new CarbonDimension(empColumnSchema, 0, 0, 0, 0, 0);
cola.setDimension(empDimension);
Expression greaterThan = new GreaterThanEqualToExpression(cola, new LiteralExpression("11", DataType.STRING));
ColumnExpression colb = new ColumnExpression("a", DataType.STRING);
colb.setDimension(true);
colb.setDimension(empDimension);
Expression lessThan = new LessThanEqualToExpression(colb, new LiteralExpression("20", DataType.STRING));
inputFilter = new AndExpression(greaterThan, lessThan);
Expression output = new AndExpression(new RangeExpression(new GreaterThanEqualToExpression(new ColumnExpression("a", DataType.STRING), new LiteralExpression("11", DataType.STRING)), new LessThanEqualToExpression(new ColumnExpression("a", DataType.STRING), new LiteralExpression("20", DataType.STRING))), new TrueExpression(null));
FilterOptimizer rangeFilterOptimizer = new RangeFilterOptmizer(new FilterOptimizerBasic(), inputFilter);
rangeFilterOptimizer.optimizeFilter();
result = checkBothTrees(inputFilter, output);
Assert.assertTrue(result);
}
Aggregations