linhongliu-db opened a new pull request, #59813:
URL: https://github.com/apache/spark/pull/59813

   ### What changes were proposed in this pull request?
   
   Reuse the existing operand-grouping helper when rendering the left operand 
of IN, including the CASE expression generated for an empty list.
   
   ### Why are the changes needed?
   
   Without grouping, `(NOT a) IN (true, false)` renders as `NOT (a) IN (true, 
false)`. With `a = true`, the intended expression is true but the generated 
expression is false. Other compound operands can also parse differently.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, a bug fix. Generated connector SQL preserves the intended meaning of 
compound IN operands. Simple column references retain their existing rendering.
   
   ### How was this patch tested?
   
   Added exact SQL assertions and 108 evaluations covering OR, NOT and 
comparison operands, TRUE/FALSE/NULL inputs, and empty or non-empty IN lists. 
The new semantic test fails on unchanged Apache code because an empty IN with 
an OR operand returns NULL instead of false. On JDK 17, all 22 V2PredicateSuite 
tests and three JDBC filter/grouping tests passed. Catalyst Java Checkstyle, 
SQL test Scalastyle and git diff --check passed.
   
   ```bash
   build/sbt 'sql/testOnly 
org.apache.spark.sql.execution.datasources.v2.V2PredicateSuite'
   build/sbt 'sql/testOnly org.apache.spark.sql.jdbc.JDBCSuite -- -z "compile 
filters" -z "IS [NOT] NULL"'
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex (GPT-6)
   


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