adriangb commented on code in PR #22698:
URL: https://github.com/apache/datafusion/pull/22698#discussion_r4027849786
##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -1164,7 +1164,55 @@ enum ShortCircuitStrategy {
/// the side that cannot short-circuit the operator is rare:
/// - for `AND`, when the proportion of `true` is less than or equal to 0.2
/// - for `OR`, when the proportion of `false` is less than or equal to 0.2
-const PRE_SELECTION_THRESHOLD: f32 = 0.2;
+pub const PRE_SELECTION_THRESHOLD: f32 = 0.2;
+
+/// How much of the batch an `AND`'s right-hand side is evaluated on, given the
+/// shape of its left-hand side's result.
+///
+/// This is the observable consequence of [`check_short_circuit`] for `AND`,
+/// exposed so that consumers modelling the cost of a conjunction share one
+/// definition with the code that implements it. See [`and_rhs_evaluation`].
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum AndRhsEvaluation {
+ /// The left-hand side is `false` on every row, so the right-hand side is
+ /// not evaluated at all.
+ Skipped,
+ /// The left-hand side has no nulls and is `true` on few enough rows
+ /// ([`PRE_SELECTION_THRESHOLD`]), so the right-hand side is evaluated only
+ /// on the rows where it is `true`.
+ PreSelected,
+ /// The right-hand side is evaluated on the whole batch. This is the case
+ /// whenever the left-hand side produces a null, however selective it
looks.
+ FullBatch,
+}
+
+/// What an `AND` does with its right-hand side, given its left-hand side's
+/// `true` count, null count and length.
+///
+/// `true_count` counts non-null `true`s; it is only consulted when
+/// `null_count` is zero, where the two conventions coincide.
+///
+/// [`check_short_circuit`] decides by this function, so a caller that models
+/// conjunction cost cannot drift away from what evaluation actually does.
+pub fn and_rhs_evaluation(
Review Comment:
Similarly, if we are making this pub just so it is cross-crate can we make
this `#[doc(hidden)]`?
##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -1164,7 +1164,55 @@ enum ShortCircuitStrategy {
/// the side that cannot short-circuit the operator is rare:
/// - for `AND`, when the proportion of `true` is less than or equal to 0.2
/// - for `OR`, when the proportion of `false` is less than or equal to 0.2
-const PRE_SELECTION_THRESHOLD: f32 = 0.2;
+pub const PRE_SELECTION_THRESHOLD: f32 = 0.2;
Review Comment:
Can we add doc hidden so this is not as strongly part of the public API?
--
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]