use of io.prestosql.sql.tree.ComparisonExpression in project hetu-core by openlookeng.
the class TestExpressionDomainTranslator method testCubeRangeVisitorRightSymbolReferenceComparisonExpression.
@Test
public void testCubeRangeVisitorRightSymbolReferenceComparisonExpression() {
CubeRangeCanonicalizer.CubeRangeVisitor visitor = new CubeRangeCanonicalizer.CubeRangeVisitor(TYPES, metadata, TEST_SESSION.toConnectorSession());
Expression cubePredicate = new ComparisonExpression(EQUAL, new LongLiteral("1"), new SymbolReference(C_TINYINT.getName()));
List<Expression> predicates = ExpressionUtils.extractDisjuncts(cubePredicate);
Expression transformed = ExpressionUtils.or(predicates.stream().map(visitor::process).collect(Collectors.toList()));
assertNotNull(transformed);
}
use of io.prestosql.sql.tree.ComparisonExpression in project hetu-core by openlookeng.
the class TestExpressionDomainTranslator method testCubeRangeVisitorRightCastedSymbolReferenceComparisonExpression.
@Test
public void testCubeRangeVisitorRightCastedSymbolReferenceComparisonExpression() {
CubeRangeCanonicalizer.CubeRangeVisitor visitor = new CubeRangeCanonicalizer.CubeRangeVisitor(TYPES, metadata, TEST_SESSION.toConnectorSession());
Expression cubePredicate = new ComparisonExpression(EQUAL, new LongLiteral("1"), new Cast(new SymbolReference(C_TINYINT.getName()), "integer"));
List<Expression> predicates = ExpressionUtils.extractDisjuncts(cubePredicate);
Expression transformed = ExpressionUtils.or(predicates.stream().map(visitor::process).collect(Collectors.toList()));
assertNotNull(transformed);
}
use of io.prestosql.sql.tree.ComparisonExpression in project hetu-core by openlookeng.
the class HeuristicIndexUtilsTest method testExtractPartitions.
@Test
public void testExtractPartitions() {
Expression equalExpName = new ComparisonExpression(EQUAL, name("a"), new LongLiteral("1"));
System.out.println(equalExpName);
assertEquals(HeuristicIndexUtils.extractPartitions(equalExpName), ImmutableList.of("a=1"));
Expression equalExpNameExp = new ComparisonExpression(EQUAL, nameExp("a"), new LongLiteral("1"));
System.out.println(equalExpNameExp);
assertEquals(HeuristicIndexUtils.extractPartitions(equalExpName), ImmutableList.of("a=1"));
Expression equalExp2Name = new ComparisonExpression(EQUAL, name("a"), new LongLiteral("2"));
System.out.println(equalExp2Name);
Expression orExp = new LogicalBinaryExpression(LogicalBinaryExpression.Operator.OR, equalExpName, equalExp2Name);
System.out.println(orExp);
assertEquals(HeuristicIndexUtils.extractPartitions(orExp), ImmutableList.of("a=1", "a=2"));
Expression inExpInteger = new InPredicate(name("a"), new InListExpression(ImmutableList.of(new LongLiteral("1"), new LongLiteral("2"), new LongLiteral("3"), new LongLiteral("4"), new LongLiteral("5"), new LongLiteral("6"))));
System.out.println(inExpInteger);
assertEquals(HeuristicIndexUtils.extractPartitions(inExpInteger), ImmutableList.of("a=1", "a=2", "a=3", "a=4", "a=5", "a=6"));
Expression inExpBigInt = new InPredicate(name("a"), new InListExpression(ImmutableList.of(bigintLiteral(1), bigintLiteral(2), bigintLiteral(3), bigintLiteral(4), bigintLiteral(5), bigintLiteral(6))));
System.out.println(inExpBigInt);
assertEquals(HeuristicIndexUtils.extractPartitions(inExpInteger), ImmutableList.of("a=1", "a=2", "a=3", "a=4", "a=5", "a=6"));
}
use of io.prestosql.sql.tree.ComparisonExpression in project hetu-core by openlookeng.
the class TestExpressionUtils method testNormalize.
@Test
public void testNormalize() {
assertNormalize(new ComparisonExpression(EQUAL, name("a"), new LongLiteral("1")));
assertNormalize(new IsNullPredicate(name("a")));
assertNormalize(new NotExpression(new LikePredicate(name("a"), new StringLiteral("x%"), Optional.empty())));
assertNormalize(new NotExpression(new ComparisonExpression(EQUAL, name("a"), new LongLiteral("1"))), new ComparisonExpression(NOT_EQUAL, name("a"), new LongLiteral("1")));
assertNormalize(new NotExpression(new ComparisonExpression(NOT_EQUAL, name("a"), new LongLiteral("1"))), new ComparisonExpression(EQUAL, name("a"), new LongLiteral("1")));
// Cannot normalize IS DISTINCT FROM yet
assertNormalize(new NotExpression(new ComparisonExpression(IS_DISTINCT_FROM, name("a"), new LongLiteral("1"))));
}
use of io.prestosql.sql.tree.ComparisonExpression in project hetu-core by openlookeng.
the class JoinStatsRule method filterByEquiJoinClauses.
private PlanNodeStatsEstimate filterByEquiJoinClauses(PlanNodeStatsEstimate stats, EquiJoinClause drivingClause, Collection<EquiJoinClause> remainingClauses, Session session, TypeProvider types) {
ComparisonExpression drivingPredicate = new ComparisonExpression(EQUAL, toSymbolReference(drivingClause.getLeft()), toSymbolReference(drivingClause.getRight()));
PlanNodeStatsEstimate filteredStats = filterStatsCalculator.filterStats(stats, drivingPredicate, session, types);
for (EquiJoinClause clause : remainingClauses) {
filteredStats = filterByAuxiliaryClause(filteredStats, clause, types);
}
return filteredStats;
}
Aggregations