1fanwang opened a new pull request, #25684:
URL: https://github.com/apache/datafusion/pull/25684

   ## Which issue does this PR close?
   
   Closes https://github.com/apache/datafusion/issues/25369
   
   ## Rationale for this change
   
   Aggregates over a repeated CASE expression can fail during planning when its 
condition refers to multiple columns. The reported SUM query now returns 1 
instead of an internal schema error.
   
   ## What changes are included in this PR?
   
   Physical CASE nullability uses the existing three-valued bounds for AND, OR 
and NOT when a condition cannot be evaluated without input rows. The 
aggregate's schema check stays unchanged.
   
   The non-nullability deduction relies on NULL AND x never being true, for any 
x, including NULL. OR and NOT must preserve the distinction between false and 
NULL; the regression tests cover both nullable and non-nullable branches.
   
   ## What is the testing strategy for this PR?
   
   The SQL regression exercises SUM, COUNT, expanded BETWEEN, NULL inputs, 
nullable or missing ELSE, and empty input. Parameterized unit tests cover both 
operand orders.
   
   On macOS arm64 with Rust 1.98.1 and the pinned test data:
   
   ```sh
   cargo test --locked --profile ci -p datafusion-sqllogictest --test 
sqllogictests -- cse.slt
   ```
   
   <details><summary>Raw logs</summary>
   
   Before:
   ```text
   Internal error: Physical input schema should be the same as the one 
converted from logical input schema. Differences:
        - field nullability at index 0 [__common_expr_1]: (physical) true vs 
(logical) false.
   Error: Execution("1 failures")
   ```
   
   After:
   ```text
   Progress: 1/1 files completed (100%)
   slt_exit_code=0
   ```
   
   </details>
   
   The physical-expression, optimizer and logical-expression crate tests and 
the CASE/CSE/aggregate SQL files pass. Formatting and Clippy pass with the 
Parquet encryption feature enabled, as in workspace CI.
   
   ## Are there any user-facing changes?
   
   The affected aggregate queries plan and run. There is no public API change.
   


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