kosiew commented on code in PR #20789:
URL: https://github.com/apache/datafusion/pull/20789#discussion_r2964834920


##########
datafusion/physical-expr/src/analysis.rs:
##########
@@ -277,8 +278,18 @@ fn calculate_selectivity(
     let mut acc: f64 = 1.0;
     for (initial, target) in initial_boundaries.iter().zip(target_boundaries) {
         match (initial.interval.as_ref(), target.interval.as_ref()) {
-            (Some(initial), Some(target)) => {
-                acc *= cardinality_ratio(initial, target);
+            (Some(initial_interval), Some(target_interval)) => {
+                // If it is equality predicate, calculate selectivity as `1 / 
distinct_count`

Review Comment:
   Small readability suggestion: would it make sense to move this 
singleton-selectivity logic into a tiny helper, maybe something like 
`singleton_selectivity(initial_interval, target_interval, distinct_count)`?
   
   I think that would make `calculate_selectivity` a bit easier to scan, and it 
would give the equality-vs-singleton rules a single place to live once the 
edge-case handling is tightened.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to