adriangb commented on code in PR #19129:
URL: https://github.com/apache/datafusion/pull/19129#discussion_r2598658652


##########
datafusion/pruning/src/pruning_predicate.rs:
##########
@@ -1545,6 +1592,48 @@ fn build_predicate_expression(
         .unwrap_or_else(|_| unhandled_hook.handle(expr))
 }
 
+/// Count of distinct column references in an expression.
+/// This is the same as [`collect_columns`] but optimized to stop counting
+/// once more than one distinct column is found.
+///
+/// For example, in expression `col1 + col2`, the count is `Many`.
+/// In expression `col1 + 5`, the count is `One`.
+/// In expression `5 + 10`, the count is `Zero`.
+#[derive(Debug, PartialEq, Eq)]
+enum ColumnReferenceCount {

Review Comment:
   This replaces `collect_columns` because:
   1. We only ever want to know if there's one or more, this short circuits / 
avoids extra work if we're going to bail anyway.
   2. Makes the match statements clearer instead of matching on `.len()` 
integers.
   3. Avoids `columns.iter().first().unwrap()` later on (even though this does 
still contain an unwrap internally)



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