use of com.facebook.presto.sql.planner.ExpressionDomainTranslator.ExtractionResult in project presto by prestodb.
the class TestExpressionDomainTranslator method testAllRoundTrip.
@Test
public void testAllRoundTrip() {
TupleDomain<String> tupleDomain = TupleDomain.all();
ExtractionResult result = fromPredicate(toPredicate(tupleDomain));
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertEquals(result.getTupleDomain(), tupleDomain);
}
use of com.facebook.presto.sql.planner.ExpressionDomainTranslator.ExtractionResult in project presto by prestodb.
the class TestExpressionDomainTranslator method assertPredicateIsAlwaysFalse.
private void assertPredicateIsAlwaysFalse(Expression expression) {
ExtractionResult result = fromPredicate(expression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertTrue(result.getTupleDomain().isNone());
}
use of com.facebook.presto.sql.planner.ExpressionDomainTranslator.ExtractionResult in project presto by prestodb.
the class TestExpressionDomainTranslator method testExpressionConstantFolding.
@Test
public void testExpressionConstantFolding() {
Expression originalExpression = comparison(GREATER_THAN, new SymbolReference(C_VARBINARY), function("from_hex", stringLiteral("123456")));
ExtractionResult result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
Slice value = Slices.wrappedBuffer(BaseEncoding.base16().decode("123456"));
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_VARBINARY, Domain.create(ValueSet.ofRanges(Range.greaterThan(VARBINARY, value)), false))));
Expression expression = toPredicate(result.getTupleDomain());
assertEquals(expression, comparison(GREATER_THAN, new SymbolReference(C_VARBINARY), varbinaryLiteral(value)));
}
use of com.facebook.presto.sql.planner.ExpressionDomainTranslator.ExtractionResult in project presto by prestodb.
the class TestExpressionDomainTranslator method testFromAndPredicate.
@Test
public void testFromAndPredicate() {
Expression originalPredicate = and(and(greaterThan(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT)), and(lessThan(C_BIGINT, bigintLiteral(5L)), unprocessableExpression2(C_BIGINT)));
ExtractionResult result = fromPredicate(originalPredicate);
assertEquals(result.getRemainingExpression(), and(unprocessableExpression1(C_BIGINT), unprocessableExpression2(C_BIGINT)));
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.range(BIGINT, 1L, false, 5L, false)), false))));
// Test complements
assertUnsupportedPredicate(not(and(and(greaterThan(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT)), and(lessThan(C_BIGINT, bigintLiteral(5L)), unprocessableExpression2(C_BIGINT)))));
originalPredicate = not(and(not(and(greaterThan(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT))), not(and(lessThan(C_BIGINT, bigintLiteral(5L)), unprocessableExpression2(C_BIGINT)))));
result = fromPredicate(originalPredicate);
assertEquals(result.getRemainingExpression(), originalPredicate);
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.notNull(BIGINT))));
}
use of com.facebook.presto.sql.planner.ExpressionDomainTranslator.ExtractionResult in project presto by prestodb.
the class TestExpressionDomainTranslator method assertUnsupportedPredicate.
private void assertUnsupportedPredicate(Expression expression) {
ExtractionResult result = fromPredicate(expression);
assertEquals(result.getRemainingExpression(), expression);
assertEquals(result.getTupleDomain(), TupleDomain.all());
}
Aggregations