You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/01/21 02:41:48 UTC

[GitHub] [calcite] liyafan82 commented on a change in pull request #2330: [CALCITE-4465] Estimate the number of distinct values by predicates

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:
users@infra.apache.org