Search in sources :

Example 11 with InExpression

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

the class FilterUtilTest method testRemoveInExpressionNodeWithPositionIdColumn.

@Test
public void testRemoveInExpressionNodeWithPositionIdColumn() {
    List<Expression> children = new ArrayList<>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
    // create literal expression
    LiteralExpression literalExpression = new LiteralExpression("0/1/0-0_batchno0-0-1517808273200/0", DataTypes.STRING);
    children.add(literalExpression);
    // create list expression
    ListExpression listExpression = new ListExpression(children);
    // create column expression with column name as positionId
    ColumnExpression columnExpression = new ColumnExpression(CarbonCommonConstants.POSITION_ID, DataTypes.STRING);
    // create InExpression as right node
    InExpression inExpression = new InExpression(columnExpression, listExpression);
    // create a dummy true expression as left node
    TrueExpression trueExpression = new TrueExpression(null);
    // create and expression as the root node
    Expression expression = new AndExpression(trueExpression, inExpression);
    // test remove expression method
    FilterUtil.removeInExpressionNodeWithPositionIdColumn(expression);
    // after removing the right node instance of right node should be of true expression
    assert (((AndExpression) expression).getRight() instanceof TrueExpression);
}
Also used : TrueExpression(org.apache.carbondata.core.scan.expression.logical.TrueExpression) AndExpression(org.apache.carbondata.core.scan.expression.logical.AndExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) AndExpression(org.apache.carbondata.core.scan.expression.logical.AndExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) ListExpression(org.apache.carbondata.core.scan.expression.conditional.ListExpression) TrueExpression(org.apache.carbondata.core.scan.expression.logical.TrueExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) InExpression(org.apache.carbondata.core.scan.expression.conditional.InExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ListExpression(org.apache.carbondata.core.scan.expression.conditional.ListExpression) InExpression(org.apache.carbondata.core.scan.expression.conditional.InExpression) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

InExpression (org.apache.carbondata.core.scan.expression.conditional.InExpression)11 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)10 LiteralExpression (org.apache.carbondata.core.scan.expression.LiteralExpression)10 ListExpression (org.apache.carbondata.core.scan.expression.conditional.ListExpression)8 AndExpression (org.apache.carbondata.core.scan.expression.logical.AndExpression)8 Expression (org.apache.carbondata.core.scan.expression.Expression)7 ArrayList (java.util.ArrayList)6 EqualToExpression (org.apache.carbondata.core.scan.expression.conditional.EqualToExpression)4 LessThanExpression (org.apache.carbondata.core.scan.expression.conditional.LessThanExpression)4 Test (org.junit.Test)4 GreaterThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression)3 GreaterThanExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression)3 LessThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression)3 TrueExpression (org.apache.carbondata.core.scan.expression.logical.TrueExpression)3 List (java.util.List)2 DataType (org.apache.carbondata.core.metadata.datatype.DataType)2 CarbonColumn (org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn)2 OrExpression (org.apache.carbondata.core.scan.expression.logical.OrExpression)2 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 Domain (com.facebook.presto.spi.predicate.Domain)1