fzlzjerry opened a new pull request, #24258: URL: https://github.com/apache/datafusion/pull/24258
## Which issue does this PR close? - Closes #24246. ## Rationale for this change Several expression simplifications erase SQL NULL semantics. For nullable inputs, identities such as `power(a, 0)`, `log(a, 1)`, and `i XOR i` can return constants instead of NULL. Set algebra over `IN` expressions and the `array_has` to `IN` rewrite can similarly change NULL or false results. ## What changes are included in this PR? - Apply the affected logarithm, power, and XOR identities only when the operand being eliminated is non-nullable. - Keep `IN`/`NOT IN` set operations unchanged when list items may be NULL, and preserve the nullable branch when an otherwise safe operation becomes a constant. - Avoid rewriting `array_has` to `IN` when a nullable array element would change the result, while retaining the safe same-expression case. - Add unit and SQL logic regression coverage for the reported expressions and their query plans. ## Are these changes tested? Yes. The following checks pass: - `./dev/rust_lint.sh` - `cargo test --profile=ci -p datafusion-functions -p datafusion-functions-nested -p datafusion-optimizer --lib` - `cargo test --profile=ci --test sqllogictests` - `RUST_BACKTRACE=1 prlimit --nofile=65536:65536 -- cargo test --profile ci --exclude datafusion-examples --exclude datafusion-benchmarks --exclude datafusion-cli --workspace --lib --tests --bins --features avro,json,backtrace,extended_tests,recursive_protection,parquet_encryption` ## Are there any user-facing changes? Yes. Expressions involving nullable inputs now retain their SQL three-valued-logic results instead of being simplified to incorrect constants. There are no public API changes. -- 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]
