Search in sources :

Example 6 with InListExpression

use of com.facebook.presto.sql.tree.InListExpression in project presto by prestodb.

the class TestDomainTranslator method testFromUnprocessableInPredicate.

@Test
public void testFromUnprocessableInPredicate() throws Exception {
    Expression originalExpression = new InPredicate(unprocessableExpression1(C_BIGINT), new InListExpression(ImmutableList.of(TRUE_LITERAL)));
    ExtractionResult result = fromPredicate(originalExpression);
    assertEquals(result.getRemainingExpression(), originalExpression);
    assertTrue(result.getTupleDomain().isAll());
    originalExpression = new InPredicate(C_BOOLEAN.toSymbolReference(), new InListExpression(ImmutableList.of(unprocessableExpression1(C_BOOLEAN))));
    result = fromPredicate(originalExpression);
    assertEquals(result.getRemainingExpression(), equal(C_BOOLEAN, unprocessableExpression1(C_BOOLEAN)));
    assertTrue(result.getTupleDomain().isAll());
    originalExpression = new InPredicate(C_BOOLEAN.toSymbolReference(), new InListExpression(ImmutableList.of(TRUE_LITERAL, unprocessableExpression1(C_BOOLEAN))));
    result = fromPredicate(originalExpression);
    assertEquals(result.getRemainingExpression(), or(equal(C_BOOLEAN, TRUE_LITERAL), equal(C_BOOLEAN, unprocessableExpression1(C_BOOLEAN))));
    assertTrue(result.getTupleDomain().isAll());
    // Test complement
    originalExpression = not(new InPredicate(C_BOOLEAN.toSymbolReference(), new InListExpression(ImmutableList.of(unprocessableExpression1(C_BOOLEAN)))));
    result = fromPredicate(originalExpression);
    assertEquals(result.getRemainingExpression(), not(equal(C_BOOLEAN, unprocessableExpression1(C_BOOLEAN))));
    assertTrue(result.getTupleDomain().isAll());
}
Also used : NotExpression(com.facebook.presto.sql.tree.NotExpression) InListExpression(com.facebook.presto.sql.tree.InListExpression) ComparisonExpression(com.facebook.presto.sql.tree.ComparisonExpression) LiteralInterpreter.toExpression(com.facebook.presto.sql.planner.LiteralInterpreter.toExpression) Expression(com.facebook.presto.sql.tree.Expression) InListExpression(com.facebook.presto.sql.tree.InListExpression) ExtractionResult(com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult) InPredicate(com.facebook.presto.sql.tree.InPredicate) Test(org.testng.annotations.Test)

Aggregations

ComparisonExpression (com.facebook.presto.sql.tree.ComparisonExpression)6 Expression (com.facebook.presto.sql.tree.Expression)6 InListExpression (com.facebook.presto.sql.tree.InListExpression)6 InPredicate (com.facebook.presto.sql.tree.InPredicate)6 NotExpression (com.facebook.presto.sql.tree.NotExpression)5 LiteralInterpreter.toExpression (com.facebook.presto.sql.planner.LiteralInterpreter.toExpression)4 LogicalBinaryExpression (com.facebook.presto.sql.tree.LogicalBinaryExpression)3 Range (com.facebook.presto.spi.predicate.Range)2 SortedRangeSet (com.facebook.presto.spi.predicate.SortedRangeSet)2 Type (com.facebook.presto.spi.type.Type)2 ArithmeticBinaryExpression (com.facebook.presto.sql.tree.ArithmeticBinaryExpression)2 ComparisonExpressionType (com.facebook.presto.sql.tree.ComparisonExpressionType)2 Test (org.testng.annotations.Test)2 Session (com.facebook.presto.Session)1 Metadata (com.facebook.presto.metadata.Metadata)1 Signature (com.facebook.presto.metadata.Signature)1 Signature.internalOperator (com.facebook.presto.metadata.Signature.internalOperator)1 Block (com.facebook.presto.spi.block.Block)1 SATURATED_FLOOR_CAST (com.facebook.presto.spi.function.OperatorType.SATURATED_FLOOR_CAST)1 DiscreteValues (com.facebook.presto.spi.predicate.DiscreteValues)1