Examples of ExtractionResult


Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

    @Test
    public void testFromBooleanLiteralPredicate()
            throws Exception
    {
        Expression originalExpression = TRUE_LITERAL;
        ExtractionResult result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertTrue(result.getTupleDomain().isAll());

        originalExpression = not(TRUE_LITERAL);
        result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertTrue(result.getTupleDomain().isNone());

        originalExpression = FALSE_LITERAL;
        result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertTrue(result.getTupleDomain().isNone());

        originalExpression = not(FALSE_LITERAL);
        result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertTrue(result.getTupleDomain().isAll());
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

    @Test
    public void testFromNullLiteralPredicate()
            throws Exception
    {
        Expression originalExpression = nullLiteral();
        ExtractionResult result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertTrue(result.getTupleDomain().isNone());

        originalExpression = not(nullLiteral());
        result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertTrue(result.getTupleDomain().isNone());
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

    @Test
    public void testNoneRoundTrip()
            throws Exception
    {
        TupleDomain<ColumnHandle> tupleDomain = TupleDomain.none();
        ExtractionResult result = fromPredicate(MANAGER, SESSION, toPredicate(tupleDomain, COLUMN_HANDLES.inverse(), TYPES), TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertEquals(result.getTupleDomain(), tupleDomain);
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

    @Test
    public void testAllRoundTrip()
            throws Exception
    {
        TupleDomain<ColumnHandle> tupleDomain = TupleDomain.all();
        ExtractionResult result = fromPredicate(MANAGER, SESSION, toPredicate(tupleDomain, COLUMN_HANDLES.inverse(), TYPES), TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertEquals(result.getTupleDomain(), tupleDomain);
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

                .put(ECH, Domain.singleValue(2L))
                .put(FCH, Domain.create(SortedRangeSet.of(Range.lessThanOrEqual(1.1), Range.equal(2.0), Range.range(3.0, false, 3.5, true)), true))
                .put(GCH, Domain.create(SortedRangeSet.of(Range.lessThanOrEqual(utf8Slice("2013-01-01")), Range.greaterThan(utf8Slice("2013-10-01"))), false))
                .build());

        ExtractionResult result = fromPredicate(MANAGER, SESSION, toPredicate(tupleDomain, COLUMN_HANDLES.inverse(), TYPES), TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertEquals(result.getTupleDomain(), tupleDomain);
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

                .put(BCH, Domain.onlyNull(Double.class))
                .put(CCH, Domain.notNull(Slice.class))
                .put(DCH, Domain.all(Boolean.class))
                .build());

        ExtractionResult result = fromPredicate(MANAGER, SESSION, toPredicate(tupleDomain, COLUMN_HANDLES.inverse(), TYPES), TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>builder()
                .put(ACH, Domain.singleValue(1L))
                .put(BCH, Domain.onlyNull(Double.class))
                .put(CCH, Domain.notNull(Slice.class))
                .build()));
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

    @Test
    public void testFromUnknownPredicate()
            throws Exception
    {
        ExtractionResult result = fromPredicate(MANAGER, SESSION, unprocessableExpression1(A), TYPES, COLUMN_HANDLES);
        Assert.assertTrue(result.getTupleDomain().isAll());
        Assert.assertEquals(result.getRemainingExpression(), unprocessableExpression1(A));

        // Test the complement
        result = fromPredicate(MANAGER, SESSION, not(unprocessableExpression1(A)), TYPES, COLUMN_HANDLES);
        Assert.assertTrue(result.getTupleDomain().isAll());
        Assert.assertEquals(result.getRemainingExpression(), not(unprocessableExpression1(A)));
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

            throws Exception
    {
        Expression originalPredicate = and(
                and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A)),
                and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A)));
        ExtractionResult result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), and(unprocessableExpression1(A), unprocessableExpression2(A)));
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.create(SortedRangeSet.of(Range.range(1L, false, 5L, false)), false))));

        // Test complements
        originalPredicate = not(and(
                and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A)),
                and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A))));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), originalPredicate);
        Assert.assertTrue(result.getTupleDomain().isAll());

        originalPredicate = not(and(
                not(and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A))),
                not(and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A)))));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), originalPredicate);
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.notNull(Long.class))));
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

            throws Exception
    {
        Expression originalPredicate = or(
                and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A)),
                and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A)));
        ExtractionResult result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), originalPredicate);
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.notNull(Long.class))));

        originalPredicate = or(
                and(equal(A, longLiteral(1L)), unprocessableExpression1(A)),
                and(equal(A, longLiteral(2L)), unprocessableExpression2(A)));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), originalPredicate);
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.create(SortedRangeSet.of(Range.equal(1L), Range.equal(2L)), false))));

        // Same unprocessableExpression means that we can do more extraction
        // If both sides are operating on the same single symbol
        originalPredicate = or(
                and(equal(A, longLiteral(1L)), unprocessableExpression1(A)),
                and(equal(A, longLiteral(2L)), unprocessableExpression1(A)));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), unprocessableExpression1(A));
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.create(SortedRangeSet.of(Range.equal(1L), Range.equal(2L)), false))));

        // And not if they have different symbols
        originalPredicate = or(
                and(equal(A, longLiteral(1L)), unprocessableExpression1(A)),
                and(equal(B, doubleLiteral(2.0)), unprocessableExpression1(A)));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), originalPredicate);
        Assert.assertTrue(result.getTupleDomain().isAll());

        // We can make another optimization if one side is the super set of the other side
        originalPredicate = or(
                and(greaterThan(A, longLiteral(1L)), greaterThan(B, doubleLiteral(1.0)), unprocessableExpression1(A)),
                and(greaterThan(A, longLiteral(2L)), greaterThan(B, doubleLiteral(2.0)), unprocessableExpression1(A)));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), unprocessableExpression1(A));
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(
                ACH, Domain.create(SortedRangeSet.of(Range.greaterThan(1L)), false),
                BCH, Domain.create(SortedRangeSet.of(Range.greaterThan(1.0)), false))));

        // We can't make those inferences if the unprocessableExpressions are non-deterministic
        originalPredicate = or(
                and(equal(A, longLiteral(1L)), randPredicate(A)),
                and(equal(A, longLiteral(2L)), randPredicate(A)));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), originalPredicate);
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.create(SortedRangeSet.of(Range.equal(1L), Range.equal(2L)), false))));

        // Test complements
        originalPredicate = not(or(
                and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A)),
                and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A))));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), and(
                not(and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A))),
                not(and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A)))));
        Assert.assertTrue(result.getTupleDomain().isAll());

        originalPredicate = not(or(
                not(and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A))),
                not(and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A)))));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), and(unprocessableExpression1(A), unprocessableExpression2(A)));
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.create(SortedRangeSet.of(Range.range(1L, false, 5L, false)), false))));
    }
View Full Code Here

Examples of com.facebook.presto.sql.planner.DomainTranslator.ExtractionResult

    @Test
    public void testFromNotPredicate()
            throws Exception
    {
        Expression originalPredicate = not(and(equal(A, longLiteral(1L)), unprocessableExpression1(A)));
        ExtractionResult result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), originalPredicate);
        Assert.assertTrue(result.getTupleDomain().isAll());

        originalPredicate = not(unprocessableExpression1(A));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), originalPredicate);
        Assert.assertTrue(result.getTupleDomain().isAll());

        originalPredicate = not(TRUE_LITERAL);
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertTrue(result.getTupleDomain().isNone());

        originalPredicate = not(equal(A, longLiteral(1L)));
        result = fromPredicate(MANAGER, SESSION, originalPredicate, TYPES, COLUMN_HANDLES);
        Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
        Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.create(SortedRangeSet.of(Range.lessThan(1L), Range.greaterThan(1L)), false))));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.