You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/08/20 00:44:49 UTC

(datafusion) 01/01: doc: more comments to `evaluate_selection` function (#24485)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-24485-5c1211439efd3d58b9fa39f27ac1d3b18c603b33
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 47e47656eb4bb2f74ccf4504263657ebb3dda6fe
Author: Yongting You <20...@gmail.com>
AuthorDate: Thu Aug 20 00:44:26 2026 +0000

    doc: more comments to `evaluate_selection` function (#24485)
    
    ## Which issue does this PR close?
    
    <!--
    We generally require a GitHub issue to be filed for all bug fixes and
    enhancements and this helps us generate change logs for our releases.
    You can link an issue to this PR using the GitHub syntax. For example
    `Closes #123` indicates that this PR will close issue #123.
    -->
    
    - Closes #.
    
    ## Rationale for this change
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand
    your changes and offer better suggestions for fixes.
    
    Please explain the problem you are trying to solve in terms of the
    user-visible
    behavior, rather than the implementation.
    
    For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of
    the
    implementation. "COUNT(DISTINCT) returns wrong results when the column
    contains
    nulls" is the user-visible problem.
    -->
    
    ## What changes are included in this PR?
    
    <!--
    There is no need to duplicate the description in the issue here, but it
    is sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    
    ## Are these changes tested?
    
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they covered by existing tests)?
    -->
    
    ## Are there any user-facing changes?
    
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    
    If there are any breaking changes to public APIs, please add the `api
    change` label.
    -->
---
 .../physical-expr-common/src/physical_expr.rs      | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/datafusion/physical-expr-common/src/physical_expr.rs b/datafusion/physical-expr-common/src/physical_expr.rs
index 59393e7578..6be291881e 100644
--- a/datafusion/physical-expr-common/src/physical_expr.rs
+++ b/datafusion/physical-expr-common/src/physical_expr.rs
@@ -93,12 +93,30 @@ pub trait PhysicalExpr: Any + Send + Sync + Display + Debug + DynEq + DynHash {
             self.nullable(input_schema)?,
         )))
     }
-    /// Evaluate an expression against a RecordBatch after first applying a validity array
+    /// Evaluates this expression only for rows where `selection` is `true`.
+    ///
+    /// Rows where `selection` is `false` or null are skipped during evaluation and
+    /// produce `NULL` in the result. Thus, values in those rows cannot trigger
+    /// evaluation errors such as division by zero.
+    ///
+    /// # Example
+    ///
+    /// Given `expr = 4 / val`:
+    ///
+    /// ```text
+    /// val  selection | result
+    ///   0      false |   NULL
+    ///   1       true |      4
+    ///   2       true |      2
+    /// ```
+    ///
+    /// The first row is not evaluated, avoiding division by zero. Its result is
+    /// `NULL`.
     ///
     /// # Errors
     ///
-    /// Returns an `Err` if the expression could not be evaluated or if the length of the
-    /// `selection` validity array and the number of row in `batch` is not equal.
+    /// Returns an `Err` if the expression could not be evaluated or if the length of
+    /// `selection` does not equal the number of rows in `batch`.
     fn evaluate_selection(
         &self,
         batch: &RecordBatch,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org