silundong commented on code in PR #4459:
URL: https://github.com/apache/calcite/pull/4459#discussion_r2191548934


##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java:
##########
@@ -172,12 +172,18 @@ protected RelMdDistinctRowCount() {}
         return 1D;
       }
     }
+    // the result of the aggregation function is difficult to infer, so if the 
groupKey contains
+    // the aggregated column, return the full row count of Aggregate. This is 
the most conservative
+    // estimate, and the actual ndv will not be greater than it.
+    if (groupKey.anyMatch(key -> key >= rel.getGroupCount())) {

Review Comment:
   Here is to solve the issue mentioned in jira:
   > if there is any aggregated column in the queried group key, then it makes 
no sense to query the distinct values on the aggregate input, the handler 
should return null or (at most) the full cardinal of the aggregate.
   
   If the index in groupKey is greater than the group count of Aggregate, then 
the index represents aggCall of Aggregate.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to