Search in sources :

Example 26 with Expression

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);
}
Also used : CarbonColumn(org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) ListExpression(org.apache.carbondata.core.scan.expression.conditional.ListExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) MockUp(mockit.MockUp) Test(org.junit.Test) AbstractDictionaryCacheTest(org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)

Example 27 with Expression

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);
}
Also used : ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) ListExpression(org.apache.carbondata.core.scan.expression.conditional.ListExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) Test(org.junit.Test) AbstractDictionaryCacheTest(org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)

Example 28 with Expression

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);
}
Also used : CarbonColumn(org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) ListExpression(org.apache.carbondata.core.scan.expression.conditional.ListExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) MockUp(mockit.MockUp) Test(org.junit.Test) AbstractDictionaryCacheTest(org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)

Example 29 with Expression

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());
        }
    }
}
Also used : ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) ArrayList(java.util.ArrayList)

Example 30 with Expression

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);
}
Also used : FilterOptimizer(org.apache.carbondata.core.scan.filter.intf.FilterOptimizer) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) LessThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) GreaterThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression) TrueExpression(org.apache.carbondata.core.scan.expression.logical.TrueExpression) AndExpression(org.apache.carbondata.core.scan.expression.logical.AndExpression) LessThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) GreaterThanExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression) AndExpression(org.apache.carbondata.core.scan.expression.logical.AndExpression) GreaterThanEqualToExpression(org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) OrExpression(org.apache.carbondata.core.scan.expression.logical.OrExpression) TrueExpression(org.apache.carbondata.core.scan.expression.logical.TrueExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) NotEqualsExpression(org.apache.carbondata.core.scan.expression.conditional.NotEqualsExpression) RangeExpression(org.apache.carbondata.core.scan.expression.logical.RangeExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) RangeFilterOptmizer(org.apache.carbondata.core.scan.filter.optimizer.RangeFilterOptmizer) FilterOptimizerBasic(org.apache.carbondata.core.scan.filter.intf.FilterOptimizerBasic) Test(org.junit.Test)

Aggregations

Expression (org.apache.carbondata.core.scan.expression.Expression)31 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)25 LiteralExpression (org.apache.carbondata.core.scan.expression.LiteralExpression)24 Test (org.junit.Test)18 ListExpression (org.apache.carbondata.core.scan.expression.conditional.ListExpression)10 AbstractDictionaryCacheTest (org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)9 AndExpression (org.apache.carbondata.core.scan.expression.logical.AndExpression)7 OrExpression (org.apache.carbondata.core.scan.expression.logical.OrExpression)7 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)6 ArrayList (java.util.ArrayList)5 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)5 RangeExpression (org.apache.carbondata.core.scan.expression.logical.RangeExpression)5 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)4 CarbonColumn (org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn)4 EqualToExpression (org.apache.carbondata.core.scan.expression.conditional.EqualToExpression)4 GreaterThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression)4 GreaterThanExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression)4 LessThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression)4 NotEqualsExpression (org.apache.carbondata.core.scan.expression.conditional.NotEqualsExpression)4 TrueExpression (org.apache.carbondata.core.scan.expression.logical.TrueExpression)4