Search in sources :

Example 1 with LiteralInterpreter.toExpression

use of com.facebook.presto.sql.planner.LiteralInterpreter.toExpression in project presto by prestodb.

the class TestDomainTranslator method testNonImplictCastOnSymbolSide.

@Test
void testNonImplictCastOnSymbolSide() {
    // we expect TupleDomain.all here().
    // see comment in DomainTranslator.Visitor.visitComparisonExpression()
    // CAST(timestamp as DATE) = date_literal
    Expression originalExpression = equal(new Cast(C_TIMESTAMP.toSymbolReference(), DATE.toString()), LiteralInterpreter.toExpression(DATE_VALUE, DATE));
    ExtractionResult result = fromPredicate(originalExpression);
    assertEquals(result.getRemainingExpression(), originalExpression);
    assertEquals(result.getTupleDomain(), TupleDomain.all());
    // CAST(DECIMAL as BIGINT) = bigint_literal
    originalExpression = equal(new Cast(C_DECIMAL_12_2.toSymbolReference(), BIGINT.toString()), bigintLiteral(135L));
    result = fromPredicate(originalExpression);
    assertEquals(result.getRemainingExpression(), originalExpression);
    assertEquals(result.getTupleDomain(), TupleDomain.all());
}
Also used : Cast(com.facebook.presto.sql.tree.Cast) 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) ExtractionResult(com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult) Test(org.testng.annotations.Test)

Aggregations

ExtractionResult (com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult)1 LiteralInterpreter.toExpression (com.facebook.presto.sql.planner.LiteralInterpreter.toExpression)1 Cast (com.facebook.presto.sql.tree.Cast)1 ComparisonExpression (com.facebook.presto.sql.tree.ComparisonExpression)1 Expression (com.facebook.presto.sql.tree.Expression)1 InListExpression (com.facebook.presto.sql.tree.InListExpression)1 NotExpression (com.facebook.presto.sql.tree.NotExpression)1 Test (org.testng.annotations.Test)1