use of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestDomainTranslator method testSimpleComparison.
private static void testSimpleComparison(Expression expression, Symbol symbol, Domain domain) {
ExtractionResult result = fromPredicate(expression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
TupleDomain<Symbol> actual = result.getTupleDomain();
TupleDomain<Symbol> expected = withColumnDomains(ImmutableMap.of(symbol, domain));
if (!actual.equals(expected)) {
fail(format("for comparison [%s] expected %s but found %s", expression.toString(), expected.toString(SESSION), actual.toString(SESSION)));
}
}
use of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestDomainTranslator method testAllRoundTrip.
@Test
public void testAllRoundTrip() throws Exception {
TupleDomain<Symbol> tupleDomain = TupleDomain.all();
ExtractionResult result = fromPredicate(toPredicate(tupleDomain));
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertEquals(result.getTupleDomain(), tupleDomain);
}
use of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestDomainTranslator method testFromBooleanLiteralPredicate.
@Test
public void testFromBooleanLiteralPredicate() throws Exception {
Expression originalExpression = TRUE_LITERAL;
ExtractionResult result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertTrue(result.getTupleDomain().isAll());
originalExpression = not(TRUE_LITERAL);
result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertTrue(result.getTupleDomain().isNone());
originalExpression = FALSE_LITERAL;
result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertTrue(result.getTupleDomain().isNone());
originalExpression = not(FALSE_LITERAL);
result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertTrue(result.getTupleDomain().isAll());
}
use of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestDomainTranslator method testFromIsNotNullPredicate.
@Test
public void testFromIsNotNullPredicate() throws Exception {
Expression originalExpression = isNotNull(C_BIGINT);
ExtractionResult result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.notNull(BIGINT))));
originalExpression = isNotNull(C_HYPER_LOG_LOG);
result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_HYPER_LOG_LOG, Domain.notNull(HYPER_LOG_LOG))));
originalExpression = not(isNotNull(C_BIGINT));
result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.onlyNull(BIGINT))));
originalExpression = not(isNotNull(C_HYPER_LOG_LOG));
result = fromPredicate(originalExpression);
assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_HYPER_LOG_LOG, Domain.onlyNull(HYPER_LOG_LOG))));
}
use of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestDomainTranslator method testFromUnknownPredicate.
@Test
public void testFromUnknownPredicate() throws Exception {
ExtractionResult result = fromPredicate(unprocessableExpression1(C_BIGINT));
assertTrue(result.getTupleDomain().isAll());
assertEquals(result.getRemainingExpression(), unprocessableExpression1(C_BIGINT));
// Test the complement
result = fromPredicate(not(unprocessableExpression1(C_BIGINT)));
assertTrue(result.getTupleDomain().isAll());
assertEquals(result.getRemainingExpression(), not(unprocessableExpression1(C_BIGINT)));
}
Aggregations