@Test public void testFromNullLiteralPredicate() { assertPredicateIsAlwaysFalse(nullLiteral()); assertPredicateIsAlwaysFalse(not(nullLiteral())); }
assertPredicateIsAlwaysFalse(greaterThan(C_BIGINT, nullLiteral(BIGINT))); greaterThan(C_VARCHAR, nullLiteral(VARCHAR)), withColumnDomains(ImmutableMap.of(C_VARCHAR, Domain.create(ValueSet.none(VARCHAR), false)))); assertPredicateIsAlwaysFalse(greaterThanOrEqual(C_BIGINT, nullLiteral(BIGINT))); assertPredicateIsAlwaysFalse(lessThan(C_BIGINT, nullLiteral(BIGINT))); assertPredicateIsAlwaysFalse(lessThanOrEqual(C_BIGINT, nullLiteral(BIGINT))); assertPredicateIsAlwaysFalse(equal(C_BIGINT, nullLiteral(BIGINT))); assertPredicateIsAlwaysFalse(equal(C_COLOR, nullLiteral(COLOR))); assertPredicateIsAlwaysFalse(notEqual(C_BIGINT, nullLiteral(BIGINT))); assertPredicateIsAlwaysFalse(notEqual(C_COLOR, nullLiteral(COLOR))); isDistinctFrom(C_BIGINT, nullLiteral(BIGINT)), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.notNull(BIGINT)))); isDistinctFrom(C_COLOR, nullLiteral(COLOR)), withColumnDomains(ImmutableMap.of(C_COLOR, Domain.notNull(COLOR)))); assertPredicateIsAlwaysFalse(not(greaterThan(C_BIGINT, nullLiteral(BIGINT)))); assertPredicateIsAlwaysFalse(not(greaterThanOrEqual(C_BIGINT, nullLiteral(BIGINT)))); assertPredicateIsAlwaysFalse(not(lessThan(C_BIGINT, nullLiteral(BIGINT)))); assertPredicateIsAlwaysFalse(not(lessThanOrEqual(C_BIGINT, nullLiteral(BIGINT)))); assertPredicateIsAlwaysFalse(not(equal(C_BIGINT, nullLiteral(BIGINT)))); assertPredicateIsAlwaysFalse(not(equal(C_COLOR, nullLiteral(COLOR)))); assertPredicateIsAlwaysFalse(not(notEqual(C_BIGINT, nullLiteral(BIGINT)))); assertPredicateIsAlwaysFalse(not(notEqual(C_COLOR, nullLiteral(COLOR)))); not(isDistinctFrom(C_BIGINT, nullLiteral(BIGINT))),
@Test public void testFromBetweenPredicate() { assertPredicateTranslates( between(C_BIGINT, bigintLiteral(1L), bigintLiteral(2L)), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.range(BIGINT, 1L, true, 2L, true)), false)))); assertPredicateTranslates( between(cast(C_INTEGER, DOUBLE), cast(bigintLiteral(1L), DOUBLE), doubleLiteral(2.1)), withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.range(INTEGER, 1L, true, 2L, true)), false)))); assertPredicateIsAlwaysFalse(between(C_BIGINT, bigintLiteral(1L), nullLiteral(BIGINT))); // Test complements assertPredicateTranslates( not(between(C_BIGINT, bigintLiteral(1L), bigintLiteral(2L))), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L), Range.greaterThan(BIGINT, 2L)), false)))); assertPredicateTranslates( not(between(cast(C_INTEGER, DOUBLE), cast(bigintLiteral(1L), DOUBLE), doubleLiteral(2.1))), withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.lessThan(INTEGER, 1L), Range.greaterThan(INTEGER, 2L)), false)))); assertPredicateTranslates( not(between(C_BIGINT, bigintLiteral(1L), nullLiteral(BIGINT))), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L)), false)))); }
comparison(IS_DISTINCT_FROM, nullLiteral(BIGINT), C_BIGINT.toSymbolReference()), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.notNull(BIGINT))));
@Test public void testFromNullLiteralPredicate() throws Exception { Expression originalExpression = nullLiteral(); ExtractionResult result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalExpression = not(nullLiteral()); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); }
Expression originalExpression = greaterThan(A, nullLiteral()); ExtractionResult result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalExpression = greaterThan(C, new Cast(nullLiteral(), StandardTypes.VARCHAR)); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(C, Domain.create(ValueSet.none(VARCHAR), false)))); originalExpression = greaterThanOrEqual(A, nullLiteral()); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalExpression = lessThan(A, nullLiteral()); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalExpression = lessThanOrEqual(A, nullLiteral()); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalExpression = equal(A, nullLiteral()); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone());
@Test public void testFromBetweenPredicate() throws Exception { Expression originalExpression = between(A, longLiteral(1L), longLiteral(2L)); ExtractionResult result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.range(BIGINT, 1L, true, 2L, true)), false)))); originalExpression = between(A, longLiteral(1L), doubleLiteral(2.1)); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.range(BIGINT, 1L, true, 2L, true)), false)))); originalExpression = between(A, longLiteral(1L), nullLiteral()); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); // Test complements originalExpression = not(between(A, longLiteral(1L), longLiteral(2L))); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L), Range.greaterThan(BIGINT, 2L)), false)))); originalExpression = not(between(A, longLiteral(1L), doubleLiteral(2.1))); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L), Range.greaterThan(BIGINT, 2L)), false)))); originalExpression = not(between(A, longLiteral(1L), nullLiteral())); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 1L)), false)))); }
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(J, Domain.create(ValueSet.of(COLOR, COLOR_VALUE_1).complement(), true)))); originalExpression = comparison(IS_DISTINCT_FROM, nullLiteral(), reference(A)); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL);