Skip to content

[SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder#56296

Open
milastdbx wants to merge 4 commits into
apache:masterfrom
milastdbx:effort/isnullfix
Open

[SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder#56296
milastdbx wants to merge 4 commits into
apache:masterfrom
milastdbx:effort/isnullfix

Conversation

@milastdbx
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

In this PR i propose we update V2 SQL builder logic to be more safe and wrap child of IsNull in paranethisis if child itself has more than 1 child.
This way we are safer from perspective of operator precedence.

Some dialects such as snowflake for example treat IS NULL as higher precedence than equality and hence can lead to correctness issues or failed queries.

Why are the changes needed?

To increase robustness of dialects inheriting this SQL builder

Does this PR introduce any user-facing change?

No

How was this patch tested?

H2 Integration test.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code
Co-authored via Claude Code

@milastdbx milastdbx changed the title Wrap IsNull and IsNotNull in brackets for V2 SQL builder [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder Jun 3, 2026
Comment thread sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala Outdated
Comment thread sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala Outdated
Comment thread sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala
Copy link
Copy Markdown
Member

@uros-b uros-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing all comments @milastdbx! Waiting for CI.

@milastdbx
Copy link
Copy Markdown
Contributor Author

Thank you for addressing all comments @milastdbx! Waiting for CI.

thanks @uros-b for review. I've added integration tests as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants