use of com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestRowExpressionDomainTranslator method testBooleanAll.
@Test
public void testBooleanAll() {
RowExpression rowExpression = or(or(equal(C_BOOLEAN, constant(true, BOOLEAN)), equal(C_BOOLEAN, constant(false, BOOLEAN))), isNull(C_BOOLEAN));
ExtractionResult result = fromPredicate(rowExpression);
TupleDomain tupleDomain = result.getTupleDomain();
assertTrue(tupleDomain.isAll());
}
use of com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestRowExpressionDomainTranslator method testFromAndPredicate.
@Test
public void testFromAndPredicate() {
RowExpression 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.spi.relation.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestRowExpressionDomainTranslator method testAllRoundTrip.
@Test
public void testAllRoundTrip() {
TupleDomain<VariableReferenceExpression> tupleDomain = TupleDomain.all();
ExtractionResult result = fromPredicate(toPredicate(tupleDomain));
assertEquals(result.getRemainingExpression(), TRUE_CONSTANT);
assertEquals(result.getTupleDomain(), tupleDomain);
}
use of com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestRowExpressionDomainTranslator method assertUnsupportedPredicate.
private void assertUnsupportedPredicate(RowExpression expression) {
ExtractionResult result = fromPredicate(expression);
assertEquals(result.getRemainingExpression(), expression);
assertEquals(result.getTupleDomain(), TupleDomain.all());
}
use of com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult in project presto by prestodb.
the class TestRowExpressionDomainTranslator method testToPredicateAllIgnored.
@Test
public void testToPredicateAllIgnored() {
TupleDomain<VariableReferenceExpression> tupleDomain = withColumnDomains(ImmutableMap.<VariableReferenceExpression, Domain>builder().put(C_BIGINT, Domain.singleValue(BIGINT, 1L)).put(C_DOUBLE, Domain.onlyNull(DOUBLE)).put(C_VARCHAR, Domain.notNull(VARCHAR)).put(C_BOOLEAN, Domain.all(BOOLEAN)).build());
ExtractionResult result = fromPredicate(toPredicate(tupleDomain));
assertEquals(result.getRemainingExpression(), TRUE_CONSTANT);
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<VariableReferenceExpression, Domain>builder().put(C_BIGINT, Domain.singleValue(BIGINT, 1L)).put(C_DOUBLE, Domain.onlyNull(DOUBLE)).put(C_VARCHAR, Domain.notNull(VARCHAR)).build()));
}
Aggregations