Search in sources :

Example 6 with ExtractionResult

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());
}
Also used : TupleDomain(com.facebook.presto.common.predicate.TupleDomain) LiteralEncoder.toRowExpression(com.facebook.presto.sql.planner.LiteralEncoder.toRowExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression) ExtractionResult(com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult) Test(org.testng.annotations.Test)

Example 7 with ExtractionResult

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))));
}
Also used : LiteralEncoder.toRowExpression(com.facebook.presto.sql.planner.LiteralEncoder.toRowExpression) RowExpression(com.facebook.presto.spi.relation.RowExpression) ExtractionResult(com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult) Test(org.testng.annotations.Test)

Example 8 with ExtractionResult

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);
}
Also used : VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) ExtractionResult(com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult) Test(org.testng.annotations.Test)

Example 9 with ExtractionResult

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());
}
Also used : ExtractionResult(com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult)

Example 10 with ExtractionResult

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()));
}
Also used : VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) ExtractionResult(com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult) Domain(com.facebook.presto.common.predicate.Domain) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) Test(org.testng.annotations.Test)

Aggregations

ExtractionResult (com.facebook.presto.spi.relation.DomainTranslator.ExtractionResult)12 Test (org.testng.annotations.Test)7 RowExpression (com.facebook.presto.spi.relation.RowExpression)5 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)5 LiteralEncoder.toRowExpression (com.facebook.presto.sql.planner.LiteralEncoder.toRowExpression)4 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)3 Logger (com.facebook.airlift.log.Logger)1 Session (com.facebook.presto.Session)1 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)1 Domain (com.facebook.presto.common.predicate.Domain)1 LogicalRowExpressions (com.facebook.presto.expressions.LogicalRowExpressions)1 LogicalRowExpressions.and (com.facebook.presto.expressions.LogicalRowExpressions.and)1 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)1 Metadata (com.facebook.presto.metadata.Metadata)1 MetadataUtil.createQualifiedObjectName (com.facebook.presto.metadata.MetadataUtil.createQualifiedObjectName)1 AccessControl (com.facebook.presto.security.AccessControl)1 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 TableHandle (com.facebook.presto.spi.TableHandle)1 WarningCollector (com.facebook.presto.spi.WarningCollector)1