Search in sources :

Example 11 with InListExpression

use of io.prestosql.sql.tree.InListExpression in project hetu-core by openlookeng.

the class TestExpressionDomainTranslator method testInPredicateWithCasts.

@Test
public void testInPredicateWithCasts() {
    assertPredicateTranslates(new InPredicate(toSymbolReference(C_BIGINT), new InListExpression(ImmutableList.of(cast(toExpression(1L, SMALLINT), BIGINT)))), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.singleValue(BIGINT, 1L))));
    assertPredicateTranslates(new InPredicate(cast(C_SMALLINT, BIGINT), new InListExpression(ImmutableList.of(toExpression(1L, BIGINT)))), withColumnDomains(ImmutableMap.of(C_SMALLINT, Domain.singleValue(SMALLINT, 1L))));
    assertUnsupportedPredicate(new InPredicate(cast(C_BIGINT, INTEGER), new InListExpression(ImmutableList.of(toExpression(1L, INTEGER)))));
}
Also used : InListExpression(io.prestosql.sql.tree.InListExpression) InPredicate(io.prestosql.sql.tree.InPredicate) Test(org.testng.annotations.Test)

Example 12 with InListExpression

use of io.prestosql.sql.tree.InListExpression in project hetu-core by openlookeng.

the class TestTupleDomainFilterUtils method in.

private InPredicate in(Expression expression, Type expressisonType, List<?> values) {
    List<Type> types = nCopies(values.size(), expressisonType);
    List<Expression> expressions = literalEncoder.toExpressions(values, types);
    return new InPredicate(expression, new InListExpression(expressions));
}
Also used : Type(io.prestosql.spi.type.Type) DecimalType.createDecimalType(io.prestosql.spi.type.DecimalType.createDecimalType) CharType.createCharType(io.prestosql.spi.type.CharType.createCharType) InListExpression(io.prestosql.sql.tree.InListExpression) NotExpression(io.prestosql.sql.tree.NotExpression) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) Expression(io.prestosql.sql.tree.Expression) InListExpression(io.prestosql.sql.tree.InListExpression) InPredicate(io.prestosql.sql.tree.InPredicate)

Aggregations

InListExpression (io.prestosql.sql.tree.InListExpression)12 InPredicate (io.prestosql.sql.tree.InPredicate)12 ComparisonExpression (io.prestosql.sql.tree.ComparisonExpression)9 Expression (io.prestosql.sql.tree.Expression)8 Test (org.testng.annotations.Test)6 LogicalBinaryExpression (io.prestosql.sql.tree.LogicalBinaryExpression)5 NotExpression (io.prestosql.sql.tree.NotExpression)5 Type (io.prestosql.spi.type.Type)4 Cast (io.prestosql.sql.tree.Cast)3 NullLiteral (io.prestosql.sql.tree.NullLiteral)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 Symbol (io.prestosql.spi.plan.Symbol)2 Range (io.prestosql.spi.predicate.Range)2 SortedRangeSet (io.prestosql.spi.predicate.SortedRangeSet)2 ArithmeticBinaryExpression (io.prestosql.sql.tree.ArithmeticBinaryExpression)2 IsNotNullPredicate (io.prestosql.sql.tree.IsNotNullPredicate)2 SimpleCaseExpression (io.prestosql.sql.tree.SimpleCaseExpression)2 ArrayList (java.util.ArrayList)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1