private static ComparisonExpression notEqual(Symbol symbol, Expression expression) { return notEqual(symbol.toSymbolReference(), expression); }
assertPredicateIsAlwaysFalse(equal(C_BIGINT, nullLiteral(BIGINT))); assertPredicateIsAlwaysFalse(equal(C_COLOR, nullLiteral(COLOR))); assertPredicateIsAlwaysFalse(notEqual(C_BIGINT, nullLiteral(BIGINT))); assertPredicateIsAlwaysFalse(notEqual(C_COLOR, nullLiteral(COLOR))); 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))));
notEqual(C_BIGINT, bigintLiteral(2L)), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L), Range.greaterThan(BIGINT, 2L)), false)))); not(notEqual(C_BIGINT, bigintLiteral(2L))), withColumnDomains(ImmutableMap.of(C_BIGINT, Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 2L)), false))));
notEqual(cast(C_INTEGER, DOUBLE), doubleLiteral(2.0)), withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.lessThan(INTEGER, 2L), Range.greaterThan(INTEGER, 2L)), false)))); notEqual(cast(C_INTEGER, DOUBLE), doubleLiteral(2.1)), withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.notNull(INTEGER)))); not(notEqual(cast(C_INTEGER, DOUBLE), doubleLiteral(2.0))), withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.create(ValueSet.ofRanges(Range.equal(INTEGER, 2L)), false)))); not(notEqual(cast(C_INTEGER, DOUBLE), doubleLiteral(2.1))), withColumnDomains(ImmutableMap.of(C_INTEGER, Domain.none(INTEGER))));
testSimpleComparison(notEqual(columnExpression, integerPositive), columnSymbol, Domain.create(ValueSet.ofRanges(Range.lessThan(columnType, columnValues.getIntegerPositive()), Range.greaterThan(columnType, columnValues.getIntegerPositive())), false)); testSimpleComparison(notEqual(columnExpression, integerNegative), columnSymbol, Domain.create(ValueSet.ofRanges(Range.lessThan(columnType, columnValues.getIntegerNegative()), Range.greaterThan(columnType, columnValues.getIntegerNegative())), false)); testSimpleComparison(notEqual(columnExpression, max), columnSymbol, Domain.notNull(columnType)); testSimpleComparison(notEqual(columnExpression, min), columnSymbol, Domain.notNull(columnType)); if (literalValues.isFractional()) { testSimpleComparison(notEqual(columnExpression, fractionalPositive), columnSymbol, Domain.notNull(columnType)); testSimpleComparison(notEqual(columnExpression, fractionalNegative), columnSymbol, Domain.notNull(columnType));
testSimpleComparison(notEqual(cast(C_CHAR, VARCHAR), stringLiteral("123456789", VARCHAR)), C_CHAR, Domain.notNull(createCharType(10))); testSimpleComparison(notEqual(cast(C_CHAR, VARCHAR), stringLiteral("1234567890", VARCHAR)), C_CHAR, Domain.create(ValueSet.ofRanges( Range.lessThan(createCharType(10), Slices.utf8Slice("1234567890")), Range.greaterThan(createCharType(10), Slices.utf8Slice("1234567890"))), false)); testSimpleComparison(notEqual(cast(C_CHAR, VARCHAR), stringLiteral("12345678901", VARCHAR)), C_CHAR, Domain.notNull(createCharType(10)));
assertTrue(result.getTupleDomain().isNone()); originalExpression = notEqual(A, nullLiteral()); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalExpression = notEqual(J, nullLiteral()); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalExpression = not(notEqual(A, nullLiteral())); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertTrue(result.getTupleDomain().isNone()); originalExpression = not(notEqual(J, nullLiteral())); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 2L)), false)))); originalExpression = notEqual(A, longLiteral(2L)); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L), Range.greaterThan(BIGINT, 2L)), false)))); originalExpression = not(notEqual(A, longLiteral(2L))); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.none(BIGINT)))); originalExpression = notEqual(A, doubleLiteral(2.0)); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 2L), Range.greaterThan(BIGINT, 2L)), false)))); originalExpression = notEqual(A, doubleLiteral(2.1)); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.notNull(BIGINT)))); originalExpression = not(notEqual(A, doubleLiteral(2.0))); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL); assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.of(A, Domain.create(ValueSet.ofRanges(Range.equal(BIGINT, 2L)), false)))); originalExpression = not(notEqual(A, doubleLiteral(2.1))); result = fromPredicate(originalExpression); assertEquals(result.getRemainingExpression(), TRUE_LITERAL);