This is an automated email from the ASF dual-hosted git repository. jhyde pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/calcite.git
commit ebf8cb2940ee04d23cf5ce25c421c3cade9b81ec Author: Julian Hyde <[email protected]> AuthorDate: Fri Jun 2 17:20:01 2023 -0700 oops, forgot test --- .../java/org/apache/calcite/rex/RexProgramTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java index 1a356e75a9..e4f10df2aa 100644 --- a/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java +++ b/core/src/test/java/org/apache/calcite/rex/RexProgramTest.java @@ -15,6 +15,9 @@ * limitations under the License. */ package org.apache.calcite.rex; + +import com.google.common.collect.TreeRangeSet; + import org.apache.calcite.avatica.util.ByteString; import org.apache.calcite.plan.RelOptPredicateList; import org.apache.calcite.plan.RelOptUtil; @@ -3078,6 +3081,22 @@ class RexProgramTest extends RexProgramTestBase { is(2), is("Sarg[[3..8], [10..20]]")); } + /** Unit test for + * <a href="https://issues.apache.org/jira/browse/CALCITE-5722">[CALCITE-5722] + * {@code Sarg.isComplementedPoints} fails with anti-points which are equal + * under {@code compareTo} but not {@code equals}</a>. */ + @SuppressWarnings("UnstableApiUsage") + @Test void testSargAntiPoint() { + final Sarg<BigDecimal> sarg = + Sarg.of(RexUnknownAs.UNKNOWN, + // Create anti-point around 1, with different scales + ImmutableRangeSet.<BigDecimal>builder() + .add(Range.lessThan(new BigDecimal("1"))) + .add(Range.greaterThan(new BigDecimal("1.00000000000"))) + .build()); + assertThat(sarg.isComplementedPoints(), is(true)); + } + @Test void testInterpreter() { assertThat(eval(trueLiteral), is(true)); assertThat(eval(nullInt), is(NullSentinel.INSTANCE));
