cloud-fan opened a new pull request, #56263: URL: https://github.com/apache/spark/pull/56263
### What changes were proposed in this pull request? Followup to https://github.com/apache/spark/pull/56085. That PR made `JDBCSQLBuilder.build()` emit `"1 = 1"` / `"1 = 0"` for `AlwaysTrue` / `AlwaysFalse` predicates. This change parenthesizes the output -- `"(1 = 1)"` / `"(1 = 0)"` -- so it remains valid SQL when the predicate is nested as an operand of a larger expression. ### Why are the changes needed? `AlwaysTrue` / `AlwaysFalse` can appear not only as a standalone `WHERE` predicate but also nested as an operand of a larger expression (e.g. when an equality against a boolean column is expanded to a null-aware form). With the bare `1 = 1`, the generated SQL inlines into invalid syntax such as `"a" = 1 = 1` or `1 = 1 IS NOT NULL`, which databases reject (e.g. PostgreSQL: `ERROR: syntax error at or near "="`). Parenthesizing produces `"a" = (1 = 1)` / `(1 = 1) IS NOT NULL`, which is valid both standalone and nested. ### Does this PR introduce _any_ user-facing change? Yes. JDBC pushed-filter SQL for `AlwaysTrue` / `AlwaysFalse` now uses `(1 = 1)` / `(1 = 0)` instead of bare `1 = 1` / `1 = 0`. This is semantically identical and fixes queries that previously generated invalid SQL when these predicates were nested. ### How was this patch tested? Extended the existing unit test in `JDBCSuite` to also cover the nested-operand case (`"a" = (1 = 1)`). Verified the test fails without the fix (`"1 = 1"` not equal to `"(1 = 1)"`) and passes with it. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code -- 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]
