@Test public void testFromUnknownPredicate() { assertUnsupportedPredicate(unprocessableExpression1(C_BIGINT)); assertUnsupportedPredicate(not(unprocessableExpression1(C_BIGINT))); }
@Test public void testFromUnprocessableComparison() { assertUnsupportedPredicate(comparison(GREATER_THAN, unprocessableExpression1(C_BIGINT), unprocessableExpression2(C_BIGINT))); assertUnsupportedPredicate(not(comparison(GREATER_THAN, unprocessableExpression1(C_BIGINT), unprocessableExpression2(C_BIGINT)))); }
@Test public void testFromUnprocessableInPredicate() { assertUnsupportedPredicate(new InPredicate(unprocessableExpression1(C_BIGINT), new InListExpression(ImmutableList.of(TRUE_LITERAL)))); assertUnsupportedPredicate(new InPredicate(C_BOOLEAN.toSymbolReference(), new InListExpression(ImmutableList.of(unprocessableExpression1(C_BOOLEAN))))); assertUnsupportedPredicate( new InPredicate(C_BOOLEAN.toSymbolReference(), new InListExpression(ImmutableList.of(TRUE_LITERAL, unprocessableExpression1(C_BOOLEAN))))); assertUnsupportedPredicate(not(new InPredicate(C_BOOLEAN.toSymbolReference(), new InListExpression(ImmutableList.of(unprocessableExpression1(C_BOOLEAN)))))); }
@Test public void testFromNotPredicate() { assertUnsupportedPredicate(not(and(equal(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT)))); assertUnsupportedPredicate(not(unprocessableExpression1(C_BIGINT))); assertPredicateIsAlwaysFalse(not(TRUE_LITERAL)); assertPredicateTranslates( not(equal(C_BIGINT, bigintLiteral(1L))), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L), Range.greaterThan(BIGINT, 1L)), false)))); }
@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)))); }
and(greaterThan(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT)), and(lessThan(C_BIGINT, bigintLiteral(5L)), unprocessableExpression2(C_BIGINT))); ExtractionResult result = fromPredicate(originalPredicate); and(equal(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT)), and(equal(C_BIGINT, bigintLiteral(2L)), unprocessableExpression2(C_BIGINT))); result = fromPredicate(originalPredicate); and(equal(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT)), and(equal(C_BIGINT, bigintLiteral(2L)), unprocessableExpression1(C_BIGINT))); result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), unprocessableExpression1(C_BIGINT)); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L), Range.equal(BIGINT, 2L)), false)))); and(equal(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT)), and(equal(C_DOUBLE, doubleLiteral(2.0)), unprocessableExpression1(C_BIGINT)))); and(greaterThan(C_BIGINT, bigintLiteral(1L)), greaterThan(C_DOUBLE, doubleLiteral(1.0)), unprocessableExpression1(C_BIGINT)), and(greaterThan(C_BIGINT, bigintLiteral(2L)), greaterThan(C_DOUBLE, doubleLiteral(2.0)), unprocessableExpression1(C_BIGINT))); result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), unprocessableExpression1(C_BIGINT)); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of( C_BIGINT, Domain.create(ValueSet.ofRanges(Range.greaterThan(BIGINT, 1L)), false), and(greaterThan(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT)), and(lessThan(C_BIGINT, bigintLiteral(5L)), unprocessableExpression2(C_BIGINT)))); result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), and( not(and(greaterThan(C_BIGINT, bigintLiteral(1L)), unprocessableExpression1(C_BIGINT))),
@Test public void testFromUnknownPredicate() throws Exception { ExtractionResult result = fromPredicate(unprocessableExpression1(A)); assertTrue(result.getTupleDomain().isAll()); assertEquals(result.getRemainingExpression(), unprocessableExpression1(A)); // Test the complement result = fromPredicate(not(unprocessableExpression1(A))); assertTrue(result.getTupleDomain().isAll()); assertEquals(result.getRemainingExpression(), not(unprocessableExpression1(A))); }
@Test public void testFromUnprocessableComparison() throws Exception { // If it is not a simple comparison, we should not try to process it Expression predicate = comparison(GREATER_THAN, unprocessableExpression1(A), unprocessableExpression2(A)); ExtractionResult result = fromPredicate(predicate); assertEquals(result.getRemainingExpression(), predicate); assertTrue(result.getTupleDomain().isAll()); // Complement predicate = not(comparison(GREATER_THAN, unprocessableExpression1(A), unprocessableExpression2(A))); result = fromPredicate(predicate); assertEquals(result.getRemainingExpression(), predicate); assertTrue(result.getTupleDomain().isAll()); }
@Test public void testFromUnprocessableInPredicate() throws Exception { Expression originalExpression = new InPredicate(unprocessableExpression1(A), new InListExpression(ImmutableList.<Expression>of(TRUE_LITERAL))); ExtractionResult result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), originalExpression); assertTrue(result.getTupleDomain().isAll()); originalExpression = new InPredicate(reference(D), new InListExpression(ImmutableList.of(unprocessableExpression1(D)))); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), equal(D, unprocessableExpression1(D))); assertTrue(result.getTupleDomain().isAll()); originalExpression = new InPredicate(reference(D), new InListExpression(ImmutableList.of(TRUE_LITERAL, unprocessableExpression1(D)))); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), or(equal(D, TRUE_LITERAL), equal(D, unprocessableExpression1(D)))); assertTrue(result.getTupleDomain().isAll()); // Test complement originalExpression = not(new InPredicate(reference(D), new InListExpression(ImmutableList.of(unprocessableExpression1(D))))); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), not(equal(D, unprocessableExpression1(D)))); assertTrue(result.getTupleDomain().isAll()); }
@Test public void testFromNotPredicate() throws Exception { Expression originalPredicate = not(and(equal(A, longLiteral(1L)), unprocessableExpression1(A))); ExtractionResult result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), originalPredicate); assertTrue(result.getTupleDomain().isAll()); originalPredicate = not(unprocessableExpression1(A)); result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), originalPredicate); assertTrue(result.getTupleDomain().isAll()); originalPredicate = not(TRUE_LITERAL); result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalPredicate = not(equal(A, longLiteral(1L))); result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L), Range.greaterThan(BIGINT, 1L)), false)))); }
@Test public void testFromAndPredicate() throws Exception { Expression originalPredicate = and( and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A)), and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A))); ExtractionResult result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), and(unprocessableExpression1(A), unprocessableExpression2(A))); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.range(BIGINT, 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(originalPredicate); assertEquals(result.getRemainingExpression(), originalPredicate); 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(originalPredicate); assertEquals(result.getRemainingExpression(), originalPredicate); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.notNull(BIGINT)))); }
and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A)), and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A))); ExtractionResult result = fromPredicate(originalPredicate); and(equal(A, longLiteral(1L)), unprocessableExpression1(A)), and(equal(A, longLiteral(2L)), unprocessableExpression2(A))); result = fromPredicate(originalPredicate); and(equal(A, longLiteral(1L)), unprocessableExpression1(A)), and(equal(A, longLiteral(2L)), unprocessableExpression1(A))); result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), unprocessableExpression1(A)); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 1L), Range.equal(BIGINT, 2L)), false)))); and(equal(A, longLiteral(1L)), unprocessableExpression1(A)), and(equal(B, doubleLiteral(2.0)), unprocessableExpression1(A))); result = fromPredicate(originalPredicate); assertEquals(result.getRemainingExpression(), originalPredicate); 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(originalPredicate); assertEquals(result.getRemainingExpression(), unprocessableExpression1(A)); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of( A, Domain.create(ValueSet.ofRanges(Range.greaterThan(BIGINT, 1L)), false), and(greaterThan(A, longLiteral(1L)), unprocessableExpression1(A)), and(lessThan(A, longLiteral(5L)), unprocessableExpression2(A)))); result = fromPredicate(originalPredicate);