Search in sources :

Example 26 with ColumnExpression

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

the class NotEqualsExpressionUnitTest method testEvaluateForNotEqualsExpressionWithDoubleDataType.

@Test
public void testEvaluateForNotEqualsExpressionWithDoubleDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
    ColumnExpression right = new ColumnExpression("right_contact", DataType.DOUBLE);
    right.setColIndex(1);
    ColumnExpression left = new ColumnExpression("left_contact", DataType.DOUBLE);
    left.setColIndex(0);
    notEqualsExpression = new NotEqualsExpression(left, right);
    RowImpl value = new RowImpl();
    Double[] row = { 445.2D };
    Double[] row1 = { 452.08D };
    Object[] objectRow = { row, row1 };
    value.setValues(objectRow);
    new MockUp<ExpressionResult>() {

        Boolean returnMockFlag = true;

        @Mock
        public Double getDouble() {
            if (returnMockFlag) {
                returnMockFlag = false;
                return 445.2D;
            } else {
                return 452.08D;
            }
        }
    };
    ExpressionResult result = notEqualsExpression.evaluate(value);
    assertTrue(result.getBoolean());
}
Also used : RowImpl(org.apache.carbondata.core.scan.filter.intf.RowImpl) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 27 with ColumnExpression

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

the class NotEqualsExpressionUnitTest method testEvaluateForNotEqualsExpressionWithLongDataType.

@Test
public void testEvaluateForNotEqualsExpressionWithLongDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
    ColumnExpression right = new ColumnExpression("right_contact", DataType.LONG);
    right.setColIndex(1);
    ColumnExpression left = new ColumnExpression("left_contact", DataType.LONG);
    left.setColIndex(0);
    notEqualsExpression = new NotEqualsExpression(left, right);
    RowImpl value = new RowImpl();
    Long[] row = { 1234567654321L };
    Long[] row1 = { 12345676541L };
    Object[] objectRow = { row, row1 };
    value.setValues(objectRow);
    new MockUp<ExpressionResult>() {

        Boolean returnMockFlag = true;

        @Mock
        public Long getLong() {
            if (returnMockFlag) {
                returnMockFlag = false;
                return 1234567654321L;
            } else {
                return 12345676541L;
            }
        }
    };
    ExpressionResult result = notEqualsExpression.evaluate(value);
    assertTrue(result.getBoolean());
}
Also used : RowImpl(org.apache.carbondata.core.scan.filter.intf.RowImpl) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 28 with ColumnExpression

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

the class FilterUtilTest method testgetFilterListForRS.

@Test
public void testgetFilterListForRS() 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;
    int ordinal = 1;
    final CarbonColumn carbonColumn = new CarbonColumn(columnSchema, ordinal, -1);
    new MockUp<ColumnExpression>() {

        @Mock
        public CarbonColumn getCarbonColumn() {
            return carbonColumn;
        }
    };
    new MockUp<RowImpl>() {

        @Mock
        public Object getVal(int index) {
            return "test";
        }
    };
    assertTrue(FilterUtil.getFilterListForRS(expression, columnExpression, defaultValues, defaultSurrogate) 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) MockUp(mockit.MockUp) Test(org.junit.Test) AbstractDictionaryCacheTest(org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)

Example 29 with ColumnExpression

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

the class FilterUtilTest method testCheckIfDataTypeNotTimeStamp.

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

Example 30 with ColumnExpression

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

the class NotInExpressionUnitTest method testEvaluateForNotInExpressionWithIntDataType.

@Test
public void testEvaluateForNotInExpressionWithIntDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
    ColumnExpression left = new ColumnExpression("left_id", DataType.INT);
    left.setColIndex(0);
    ColumnExpression right = new ColumnExpression("right_id", DataType.INT);
    right.setColIndex(1);
    notInExpression = new NotInExpression(left, right);
    RowImpl value = new RowImpl();
    Integer row = 150569;
    Integer row1 = 15052;
    Object[] objectRow = { row, row1 };
    value.setValues(objectRow);
    new MockUp<ExpressionResult>() {

        @Mock
        public Integer getInt() {
            return 15052;
        }
    };
    ExpressionResult result = notInExpression.evaluate(value);
    assertEquals(result.getDataType(), DataType.BOOLEAN);
}
Also used : RowImpl(org.apache.carbondata.core.scan.filter.intf.RowImpl) ExpressionResult(org.apache.carbondata.core.scan.expression.ExpressionResult) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) MockUp(mockit.MockUp) Test(org.junit.Test)

Aggregations

ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)119 Test (org.junit.Test)107 RowImpl (org.apache.carbondata.core.scan.filter.intf.RowImpl)83 MockUp (mockit.MockUp)77 ExpressionResult (org.apache.carbondata.core.scan.expression.ExpressionResult)76 Expression (org.apache.carbondata.core.scan.expression.Expression)20 LiteralExpression (org.apache.carbondata.core.scan.expression.LiteralExpression)18 Timestamp (java.sql.Timestamp)8 DateFormat (java.text.DateFormat)8 ParseException (java.text.ParseException)8 SimpleDateFormat (java.text.SimpleDateFormat)8 Date (java.util.Date)8 AbstractDictionaryCacheTest (org.apache.carbondata.core.cache.dictionary.AbstractDictionaryCacheTest)8 BigDecimal (java.math.BigDecimal)7 ListExpression (org.apache.carbondata.core.scan.expression.conditional.ListExpression)7 Decimal (org.apache.spark.sql.types.Decimal)7 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)6 AndExpression (org.apache.carbondata.core.scan.expression.logical.AndExpression)6 OrExpression (org.apache.carbondata.core.scan.expression.logical.OrExpression)6 RangeExpression (org.apache.carbondata.core.scan.expression.logical.RangeExpression)6