bgeng777 commented on code in PR #26155:
URL: https://github.com/apache/flink/pull/26155#discussion_r2043638392
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/metadata/SelectivityEstimator.scala:
##########
@@ -541,7 +541,14 @@ class SelectivityEstimator(rel: RelNode, mq:
FlinkRelMetadataQuery)
}
val columnInterval = mq.getColumnInterval(rel, inputRef.getIndex)
if (columnInterval == null) {
- return defaultEqualsSelectivity
+ // For types like VARCHAR, it has no 'interval' concept but may also
contain different values.
+ // We utilize ndv to get a better estimate.
+ val ndv = mq. getDistinctRowCount(rel,
ImmutableBitSet.of(inputRef.getIndex), null)
Review Comment:
Hi thanks for the review! Yes, getDistinctRowCount is accessing existing
statistics and is not doing anything non-performant. In fact, when
`convertedInterval` is defined, you can see that `getDistinctRowCount` would be
called as well to get `ndv`.
--
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]