use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class FalseExpressionTest method testEvaluate.
@Test
public void testEvaluate() throws FilterUnsupportedException, FilterIllegalMemberException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { true });
ExpressionResult actualValue = falseExpression.evaluate(rowImpl);
assertEquals(new ExpressionResult(DataType.BOOLEAN, false), actualValue);
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class OrExpressionTest method testEvaluate.
@Test
public void testEvaluate() throws FilterIllegalMemberException, FilterUnsupportedException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { false });
final ExpressionResult expressionResult = new ExpressionResult(DataType.BOOLEAN, "test");
new MockUp<ColumnExpression>() {
@Mock
public ExpressionResult evaluate(RowIntf value) {
return expressionResult;
}
};
assertTrue(orExpression.evaluate(rowImpl) instanceof ExpressionResult);
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class OrExpressionTest method testEvaluateForDefault.
@Test(expected = Exception.class)
public void testEvaluateForDefault() throws FilterUnsupportedException, FilterIllegalMemberException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { true });
final ExpressionResult expressionResult = new ExpressionResult(DataType.STRING, "test");
new MockUp<ColumnExpression>() {
@Mock
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
return expressionResult;
}
};
orExpression.evaluate(rowImpl);
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class NotInExpressionUnitTest method testEvaluateForNotInExpressionWithDecimalDataType.
@Test
public void testEvaluateForNotInExpressionWithDecimalDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
ColumnExpression left = new ColumnExpression("left_contact", DataType.DECIMAL);
left.setColIndex(0);
ColumnExpression right = new ColumnExpression("right_contact", DataType.DECIMAL);
right.setColIndex(1);
notInExpression = new NotInExpression(left, right);
RowImpl value = new RowImpl();
Decimal row = Decimal.apply(123452154.0);
Decimal row1 = Decimal.apply(1234521215454.0);
Object[] objectRow = { row, row1 };
value.setValues(objectRow);
new MockUp<ExpressionResult>() {
@Mock
public BigDecimal getDecimal() {
return new BigDecimal(1234521215454.0);
}
};
ExpressionResult result = notInExpression.evaluate(value);
assertTrue(result.getBoolean());
}
use of org.apache.carbondata.core.scan.expression.ExpressionResult in project carbondata by apache.
the class NotEqualsExpressionUnitTest method testEvaluateWithForNotEqualsExpressionDecimalDataType.
@Test
public void testEvaluateWithForNotEqualsExpressionDecimalDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
ColumnExpression right = new ColumnExpression("contact", DataType.DECIMAL);
right.setColIndex(1);
ColumnExpression left = new ColumnExpression("contact", DataType.DECIMAL);
left.setColIndex(0);
notEqualsExpression = new NotEqualsExpression(left, right);
RowImpl value = new RowImpl();
Decimal[] row = new Decimal[] { Decimal.apply(12345.0) };
Decimal[] row1 = new Decimal[] { Decimal.apply(1235445.0) };
Object[] objectRow = { row, row1 };
value.setValues(objectRow);
new MockUp<ExpressionResult>() {
Boolean returnMockFlag = true;
@Mock
public BigDecimal getDecimal() {
if (returnMockFlag) {
returnMockFlag = false;
return new BigDecimal(12345.0);
} else {
return new BigDecimal(1235445.0);
}
}
};
ExpressionResult result = notEqualsExpression.evaluate(value);
assertTrue(result.getBoolean());
}
Aggregations