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

   ### What changes were proposed in this pull request?
   
   Parenthesize NOT operands in inputToSQL, with a comment explaining why the 
existing child-count check misses this unary operator.
   
   ### Why are the changes needed?
   
   NOT has lower SQL precedence than comparisons. Ungrouped operands also 
change the IS NULL checks synthesized for null-safe equality. For example, 
`(NOT a) <=> b` with `a = true` and `b = false` should return true, but the 
ungrouped generated expression returns false.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, a bug fix. Connector comparison SQL retains the intended grouping of 
NOT, including the expansion of null-safe equality.
   
   ### How was this patch tested?
   
   Added SQL grouping assertions and 189 evaluations spanning all seven 
comparison operators, NOT on either or both sides, and every TRUE/FALSE/NULL 
input combination. The semantic regression fails on unchanged Apache code: (NOT 
a) <=> b with a=true and b=false returns false instead of true. 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