use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class RangeExpression method getLiteralsResult.
private void getLiteralsResult(Expression expression, List<ExpressionResult> listOfExp) {
for (Expression child : expression.getChildren()) {
if (child instanceof LiteralExpression) {
ExpressionResult colExp = ((LiteralExpression) child).getExpressionResult();
listOfExp.add(colExp);
} else {
getLiteralsResult(child, listOfExp);
}
}
}
use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class BinaryLogicalExpression method getColumnList.
private void getColumnList(Expression expression, List<ColumnExpression> lst) {
if (expression instanceof ColumnExpression) {
ColumnExpression colExp = (ColumnExpression) expression;
boolean found = false;
for (ColumnExpression currentColExp : lst) {
if (currentColExp.getColumnName().equals(colExp.getColumnName())) {
found = true;
colExp.setColIndex(currentColExp.getColIndex());
break;
}
}
if (!found) {
colExp.setColIndex(lst.size());
lst.add(colExp);
}
}
for (Expression child : expression.getChildren()) {
getColumnList(child, lst);
}
}
use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class BinaryLogicalExpression method getExpressionResultList.
private void getExpressionResultList(Expression binaryConditionalExpression, List<ExpressionResult> listOfExp) {
if (binaryConditionalExpression instanceof LiteralExpression) {
ExpressionResult colExp = ((LiteralExpression) binaryConditionalExpression).getExpressionResult();
listOfExp.add(colExp);
}
for (Expression child : binaryConditionalExpression.getChildren()) {
getExpressionResultList(child, listOfExp);
}
}
use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class ListExpressionUnitTest method test.
@Test
public void test() 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);
List<Expression> children = new ArrayList<>();
children.add(left);
children.add(right);
listExpression = new ListExpression(children);
RowImpl value = new RowImpl();
String row = "Row is for left";
String row1 = "I am row 1";
Object[] objectRow = { row, row1 };
value.setValues(objectRow);
String expected_value = "Row is for left";
ExpressionResult result = listExpression.evaluate(value);
assertThat(expected_value, is(equalTo(result.getList().get(0).getString())));
}
use of org.apache.carbondata.core.scan.expression.Expression in project carbondata by apache.
the class FilterUtilTest method testCheckIfExpressionContainsColumnWithExpressionNotInstanceOfColumnExpression.
@Test
public void testCheckIfExpressionContainsColumnWithExpressionNotInstanceOfColumnExpression() {
String columnName = "IMEI";
Expression expression = new LiteralExpression(columnName, DataType.STRING);
boolean result = FilterUtil.checkIfExpressionContainsColumn(expression);
assertFalse(result);
}
Aggregations