Search in sources :

Example 21 with Expression

use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.

the class FilterUtilTest method testCheckIfRightExpressionRequireEvaluationWithExpressionIsInstanceOfLiteralExpression.

@Test
public void testCheckIfRightExpressionRequireEvaluationWithExpressionIsInstanceOfLiteralExpression() {
    Expression expression = new LiteralExpression("test", DataType.STRING);
    boolean result = FilterUtil.checkIfRightExpressionRequireEvaluation(expression);
    assertFalse(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) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) Test(org.junit.Test) AbstractDictionaryCacheTest(org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)

Example 22 with Expression

use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.

the class FilterUtilTest method testCheckIfExpressionContainsColumn.

@Test
public void testCheckIfExpressionContainsColumn() {
    String columnName = "IMEI";
    Expression expression = new ColumnExpression(columnName, DataType.STRING);
    boolean result = FilterUtil.checkIfExpressionContainsColumn(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 23 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 24 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 25 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)

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