liyafan82 commented on a change in pull request #2330:
URL: https://github.com/apache/calcite/pull/2330#discussion_r561508574



##########
File path: core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
##########
@@ -2857,6 +2857,108 @@ private void checkSarg(String message, Sarg sarg,
         is(2), is("Sarg[[3..8], [10..20]]"));
   }
 
+  /** Tests {@link Sarg#numDistinctVals(RelDataType)}. */
+  @Test void testSargNdv() {
+    RelDataType nonNullableInt = 
typeFactory.createSqlType(SqlTypeName.INTEGER);
+    RelDataType nullableInt = 
typeFactory.createTypeWithNullability(nonNullableInt, true);
+
+    RelDataType nonNullableFloat = 
typeFactory.createSqlType(SqlTypeName.FLOAT);
+    RelDataType nullableFloat = 
typeFactory.createTypeWithNullability(nonNullableFloat, true);
+
+    // point: 10 (non-nullable)
+    Sarg sarg = Sarg.of(false,
+        ImmutableRangeSet.of(Range.closed(10, 10)));
+    assertThat(sarg.numDistinctVals(nonNullableInt), is(1.0));

Review comment:
       Thank you for the good suggestion.
   I have revised the code accordingly. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to