@Test
public void testFromBetweenPredicate()
throws Exception
{
Expression originalExpression = between(A, longLiteral(1L), longLiteral(2L));
ExtractionResult result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.create(SortedRangeSet.of(Range.range(1L, true, 2L, true)), false))));
originalExpression = between(A, longLiteral(1L), doubleLiteral(2.1));
result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
Assert.assertEquals(result.getTupleDomain(), withColumnDomains(ImmutableMap.<ColumnHandle, Domain>of(ACH, Domain.create(SortedRangeSet.of(Range.range(1L, true, 2L, true)), false))));
originalExpression = between(A, longLiteral(1L), nullLiteral());
result = fromPredicate(MANAGER, SESSION, originalExpression, TYPES, COLUMN_HANDLES);
Assert.assertEquals(result.getRemainingExpression(), TRUE_LITERAL);
Assert.assertTrue(result.getTupleDomain().isNone());
// Test complements
originalExpression = not(between(A, longLiteral(1L), longLiteral(2L)));
result = fromPredicate(MANAGER, SESSION, originalExpression, 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(2L)), false))));
originalExpression = not(between(A, longLiteral(1L), doubleLiteral(2.1)));
result = fromPredicate(MANAGER, SESSION, originalExpression, 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(2L)), false))));
originalExpression = not(between(A, longLiteral(1L), nullLiteral()));
result = fromPredicate(MANAGER, SESSION, originalExpression, 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)), false))));
}