use of io.prestosql.sql.tree.Expression in project hetu-core by openlookeng.
the class TestExpressionDomainTranslator method testDateType.
private void testDateType() {
mergeAndAssert(true, ExpressionUtils.or(between(C_DATE, date("2020-01-01"), date("2020-01-05")), equal(C_DATE, date("2020-01-06")), equal(C_DATE, date("2020-01-07")), and(greaterThan(C_DATE, date("2020-01-07")), lessThanOrEqual(C_DATE, date("2020-01-09"))), between(C_DATE, date("2020-01-10"), date("2020-01-15")), between(C_DATE, date("2020-01-25"), date("2020-01-29"))), between(C_DATE, date("2020-01-02"), date("2020-01-12")));
mergeAndAssert(true, ExpressionUtils.or(between(C_DATE, date("2020-01-01"), date("2020-01-05")), equal(C_DATE, date("2020-01-06")), equal(C_DATE, date("2020-01-07")), and(greaterThan(C_DATE, date("2020-01-07")), lessThanOrEqual(C_DATE, date("2020-01-09"))), between(C_DATE, date("2020-01-10"), date("2020-01-15")), between(C_DATE, date("2020-01-25"), date("2020-01-29"))), and(greaterThan(C_DATE, date("2020-01-02")), lessThan(C_DATE, date("2020-01-12"))));
mergeAndAssert(true, ExpressionUtils.or(between(C_DATE, date("2020-01-01"), date("2020-01-05")), equal(C_DATE, date("2020-01-06")), equal(C_DATE, date("2020-01-07")), and(greaterThan(C_DATE, date("2020-01-07")), lessThanOrEqual(C_DATE, date("2020-01-09"))), between(C_DATE, date("2020-01-10"), date("2020-01-15")), between(C_DATE, date("2020-01-25"), date("2020-01-29"))), or(equal(C_DATE, date("2020-01-02")), equal(C_DATE, date("2020-01-05"))));
mergeAndAssert(false, ExpressionUtils.or(between(C_DATE, date("2020-01-01"), date("2020-01-05")), equal(C_DATE, date("2020-01-06")), equal(C_DATE, date("2020-01-07")), and(greaterThan(C_DATE, date("2020-01-07")), lessThanOrEqual(C_DATE, date("2020-01-09"))), between(C_DATE, date("2020-01-10"), date("2020-01-15")), between(C_DATE, date("2020-01-25"), date("2020-01-29"))), between(C_DATE, date("2020-01-10"), date("2020-01-16")));
Expression merged = mergeAndAssert(false, ExpressionUtils.or(between(C_DATE, date("2020-01-01"), date("2020-01-04")), between(C_DATE, date("2020-01-08"), date("2020-01-10"))), between(C_DATE, date("2020-01-02"), date("2020-01-06")));
mergeAndAssert(true, ExpressionUtils.or(merged, equal(C_DATE, date("2020-01-05")), between(C_DATE, date("2020-01-06"), date("2020-01-07"))), between(C_DATE, date("2020-01-02"), date("2020-01-10")));
mergeAndAssert(true, ExpressionUtils.or(between(C_DATE, date("2020-01-01"), date("2020-01-05")), equal(C_DATE, date("2020-01-06")), equal(C_DATE, date("2020-01-07")), equal(C_DATE, nullLiteral()), and(greaterThan(C_DATE, date("2020-01-07")), lessThanOrEqual(C_DATE, date("2020-01-09"))), between(C_DATE, date("2020-01-10"), date("2020-01-15")), between(C_DATE, date("2020-01-25"), date("2020-01-29"))), between(C_DATE, date("2020-01-02"), date("2020-01-12")));
}
use of io.prestosql.sql.tree.Expression in project hetu-core by openlookeng.
the class TestExpressionDomainTranslator method testTinyIntType.
private void testTinyIntType() {
mergeAndAssert(true, ExpressionUtils.or(between(C_TINYINT, tinyIntLiteral("1"), tinyIntLiteral("5")), equal(C_TINYINT, tinyIntLiteral("6")), equal(C_TINYINT, tinyIntLiteral("7")), and(greaterThan(C_TINYINT, tinyIntLiteral("7")), lessThanOrEqual(C_TINYINT, tinyIntLiteral("9"))), between(C_TINYINT, tinyIntLiteral("10"), tinyIntLiteral("15")), between(C_TINYINT, tinyIntLiteral("25"), tinyIntLiteral("35"))), between(C_TINYINT, tinyIntLiteral("2"), tinyIntLiteral("12")));
mergeAndAssert(true, ExpressionUtils.or(between(C_TINYINT, tinyIntLiteral("1"), tinyIntLiteral("5")), equal(C_TINYINT, tinyIntLiteral("6")), equal(C_TINYINT, tinyIntLiteral("7")), and(greaterThan(C_TINYINT, tinyIntLiteral("7")), lessThanOrEqual(C_TINYINT, tinyIntLiteral("9"))), between(C_TINYINT, tinyIntLiteral("10"), tinyIntLiteral("15")), between(C_TINYINT, tinyIntLiteral("25"), tinyIntLiteral("35"))), and(greaterThan(C_TINYINT, tinyIntLiteral("2")), lessThan(C_TINYINT, tinyIntLiteral("12"))));
mergeAndAssert(true, ExpressionUtils.or(between(C_TINYINT, tinyIntLiteral("1"), tinyIntLiteral("5")), equal(C_TINYINT, tinyIntLiteral("6")), equal(C_TINYINT, tinyIntLiteral("7")), and(greaterThan(C_TINYINT, tinyIntLiteral("7")), lessThanOrEqual(C_TINYINT, tinyIntLiteral("9"))), between(C_TINYINT, tinyIntLiteral("10"), tinyIntLiteral("15")), between(C_TINYINT, tinyIntLiteral("25"), tinyIntLiteral("35"))), or(equal(C_TINYINT, tinyIntLiteral("2")), equal(C_TINYINT, tinyIntLiteral("5"))));
mergeAndAssert(false, ExpressionUtils.or(between(C_TINYINT, tinyIntLiteral("1"), tinyIntLiteral("5")), equal(C_TINYINT, tinyIntLiteral("6")), equal(C_TINYINT, tinyIntLiteral("7")), and(greaterThan(C_TINYINT, tinyIntLiteral("7")), lessThanOrEqual(C_TINYINT, tinyIntLiteral("9"))), between(C_TINYINT, tinyIntLiteral("10"), tinyIntLiteral("15")), between(C_TINYINT, tinyIntLiteral("25"), tinyIntLiteral("35"))), between(C_TINYINT, tinyIntLiteral("10"), tinyIntLiteral("16")));
Expression merged = mergeAndAssert(false, ExpressionUtils.or(between(C_TINYINT, tinyIntLiteral("1"), tinyIntLiteral("4")), between(C_TINYINT, tinyIntLiteral("8"), tinyIntLiteral("10"))), between(C_TINYINT, tinyIntLiteral("2"), tinyIntLiteral("6")));
mergeAndAssert(true, ExpressionUtils.or(merged, equal(C_TINYINT, tinyIntLiteral("5")), between(C_TINYINT, tinyIntLiteral("6"), tinyIntLiteral("7"))), between(C_TINYINT, tinyIntLiteral("2"), tinyIntLiteral("10")));
mergeAndAssert(true, ExpressionUtils.or(between(C_TINYINT, tinyIntLiteral("1"), tinyIntLiteral("5")), equal(C_TINYINT, tinyIntLiteral("6")), equal(C_TINYINT, tinyIntLiteral("7")), equal(C_TINYINT, nullLiteral()), and(greaterThan(C_TINYINT, tinyIntLiteral("7")), lessThanOrEqual(C_TINYINT, tinyIntLiteral("9"))), between(C_TINYINT, tinyIntLiteral("10"), tinyIntLiteral("15")), between(C_TINYINT, tinyIntLiteral("25"), tinyIntLiteral("35"))), between(C_TINYINT, tinyIntLiteral("2"), tinyIntLiteral("12")));
}
use of io.prestosql.sql.tree.Expression 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.Expression in project hetu-core by openlookeng.
the class TestExpressionDomainTranslator 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));
}
use of io.prestosql.sql.tree.Expression in project hetu-core by openlookeng.
the class TestExpressionDomainTranslator method testConjunctExpression.
@Test
public void testConjunctExpression() {
Expression expression = and(comparison(GREATER_THAN, toSymbolReference(C_DOUBLE), doubleLiteral(0)), comparison(GREATER_THAN, toSymbolReference(C_BIGINT), bigintLiteral(0)));
assertPredicateTranslates(expression, withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.greaterThan(BIGINT, 0L)), false), C_DOUBLE, Domain.create(ValueSet.ofRanges(Range.greaterThan(DOUBLE, .0)), false))));
assertEquals(toPredicate(fromPredicate(expression).getTupleDomain()), and(comparison(GREATER_THAN, toSymbolReference(C_BIGINT), bigintLiteral(0)), comparison(GREATER_THAN, toSymbolReference(C_DOUBLE), doubleLiteral(0))));
}
Aggregations