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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations