use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class NotInExpressionUnitTest method testEvaluateForNotInExpressionWithShortDataType.
@Test
public void testEvaluateForNotInExpressionWithShortDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
ColumnExpression left = new ColumnExpression("left_id", DataType.SHORT);
left.setColIndex(0);
ColumnExpression right = new ColumnExpression("right_id", DataType.SHORT);
right.setColIndex(1);
notInExpression = new NotInExpression(left, right);
RowImpl value = new RowImpl();
Short row = 15653;
Short row1 = 15582;
Object[] objectRow = { row, row1 };
value.setValues(objectRow);
new MockUp<ExpressionResult>() {
@Mock
public Short getShort() {
return 15582;
}
};
ExpressionResult result = notInExpression.evaluate(value);
assertEquals(result.getDataType(), DataType.BOOLEAN);
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class NotInExpressionUnitTest method testEvaluateForNotInExpressionWithLeftAndRightDifferentDataType.
@Test
public void testEvaluateForNotInExpressionWithLeftAndRightDifferentDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
ColumnExpression right = new ColumnExpression("name", DataType.STRING);
right.setColIndex(0);
ColumnExpression left = new ColumnExpression("number", DataType.INT);
left.setColIndex(1);
notInExpression = new NotInExpression(left, right);
RowImpl value = new RowImpl();
String row1 = "String1";
Integer row = 14523213;
Object[] objectRow = { row1, row };
value.setValues(objectRow);
new MockUp<ExpressionResult>() {
@Mock
public Integer getInt() {
return 145232130;
}
};
ExpressionResult result = notInExpression.evaluate(value);
assertTrue(result.getBoolean());
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class NotInExpressionUnitTest method testEvaluateForNotInExpressionWithString.
@Test
public void testEvaluateForNotInExpressionWithString() throws FilterUnsupportedException, FilterIllegalMemberException {
ColumnExpression left = new ColumnExpression("left_name", DataType.STRING);
left.setColIndex(0);
ColumnExpression right = new ColumnExpression("right_name", DataType.STRING);
right.setColIndex(1);
notInExpression = new NotInExpression(left, right);
RowImpl value = new RowImpl();
String row = "Row is for left";
String row1 = "I am row 1";
Object[] objectRow = { row, row1 };
new MockUp<ExpressionResult>() {
@Mock
public DataType getDataType() {
return DataType.STRING;
}
@Mock
public String getString() {
return "string1";
}
};
value.setValues(objectRow);
ExpressionResult result = notInExpression.evaluate(value);
assertTrue(result.getBoolean());
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class GreaterThanExpressionUnitTest method testEvaluateForGreaterThanExpressionWithDoubleDataType.
@Test
public void testEvaluateForGreaterThanExpressionWithDoubleDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
ColumnExpression right = new ColumnExpression("right_contact", DataType.DOUBLE);
right.setColIndex(0);
ColumnExpression left = new ColumnExpression("left_contact", DataType.DOUBLE);
left.setColIndex(1);
greaterThanExpression = new GreaterThanExpression(left, right);
RowImpl value = new RowImpl();
Double[] row = { 44D };
Double[] row1 = { 20D };
Object[] objectRow = { row1, row };
value.setValues(objectRow);
new MockUp<ExpressionResult>() {
Boolean returnMockFlag = true;
@Mock
public Double getDouble() {
if (returnMockFlag) {
returnMockFlag = false;
return 44D;
} else {
return 20D;
}
}
};
ExpressionResult result = greaterThanExpression.evaluate(value);
assertTrue(result.getBoolean());
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class InExpressionUnitTest method testEvaluateForInExpressionWithTimestampDataType.
@Test
public void testEvaluateForInExpressionWithTimestampDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
try {
ColumnExpression left = new ColumnExpression("left_timestamp", DataType.TIMESTAMP);
left.setColIndex(0);
ColumnExpression right = new ColumnExpression("right_timestamp", DataType.TIMESTAMP);
right.setColIndex(1);
inExpression = new InExpression(left, right);
RowImpl value = new RowImpl();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = dateFormat.parse("23/09/2007");
long time = date.getTime();
Timestamp row = new Timestamp(time);
Timestamp row1 = new Timestamp(time);
Object[] objectRow = { row, row1 };
value.setValues(objectRow);
new MockUp<ExpressionResult>() {
@Mock
public Long getTime() {
return 18465213000000L;
}
};
ExpressionResult result = inExpression.evaluate(value);
assertFalse(result.getBoolean());
} catch (ParseException e) {
System.out.println("Error while parsing " + e.getMessage());
}
}
Aggregations