You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "milastdbx (via GitHub)" <gi...@apache.org> on 2026/06/03 10:12:35 UTC
[PR] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
milastdbx opened a new pull request, #56296:
URL: https://github.com/apache/spark/pull/56296
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
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?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
To increase robustness of dialects inheriting this SQL builder
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
H2 Integration test.
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
Generated-by: Claude Code
Co-authored via 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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #56296:
URL: https://github.com/apache/spark/pull/56296#discussion_r3347663323
##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala:
##########
@@ -272,6 +272,14 @@ class JDBCV2Suite extends SharedSparkSession with ExplainSuiteHelper {
}
}
+ test("SPARK-XXXXX: IS [NOT] NULL over a composite operand is pushed down and runs on H2") {
Review Comment:
```suggestion
test("SPARK-57243: IS [NOT] NULL over a composite operand is pushed down and runs on H2") {
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #56296:
URL: https://github.com/apache/spark/pull/56296#discussion_r3365630115
##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala:
##########
@@ -105,6 +105,10 @@ private case class MsSqlServerDialect() extends JdbcDialect with NoLegacyJDBCErr
// We shouldn't propagate these queries to MsSqlServer
expr match {
case e: Predicate => e.name() match {
+ case "IS_NULL" | "IS_NOT_NULL" if e.children().head.isInstanceOf[Predicate] =>
Review Comment:
This guard applies to any predicate, but in `V2ExpressionSQLBuilder` we only handle binary comparisons like `"=", "<>", "<=>", "<", "<=", ">", ">="`. This seems a bit asymmetrical?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #56296:
URL: https://github.com/apache/spark/pull/56296#discussion_r3347681289
##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala:
##########
@@ -272,6 +272,14 @@ class JDBCV2Suite extends SharedSparkSession with ExplainSuiteHelper {
}
}
+ test("SPARK-XXXXX: IS [NOT] NULL over a composite operand is pushed down and runs on H2") {
+ val df = sql("SELECT name FROM h2.test.employee WHERE (salary = bonus) IS NOT NULL")
+ checkFiltersRemoved(df)
+ checkPushedInfo(df, "PushedFilters: [SALARY IS NOT NULL, BONUS IS NOT NULL, " +
+ "(CAST(SALARY AS double) = BONUS) IS NOT NULL]")
+ checkAnswer(df, Seq(Row("amy"), Row("alex"), Row("cathy"), Row("david"), Row("jen")))
+ }
Review Comment:
For completeness, should we also add a test case with IS NULL?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243][SQL] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4675083595
**Outdated comment at `MsSqlServerDialect.scala` line 109**
The pre-existing block comment sits directly above the new guard:
```scala
// MsSqlServer does not support boolean comparison using standard comparison operators
// We shouldn't propagate these queries to MsSqlServer
expr match {
case e: Predicate => e.name() match {
case "IS_NULL" | "IS_NOT_NULL" if isBinaryComparison(e.children().head) =>
visitUnexpectedExpr(expr) // does NOT propagate ✓
case "=" | "<>" | "<=>" | "<" | "<=" | ">" | ">=" =>
visitBinaryComparison(...) // DOES propagate — contradicts the comment
```
"We shouldn't propagate these queries" describes the bail-out but contradicts the binary comparison case that follows it. The comment was already imprecise before this PR; placing the new IS_NULL/IS_NOT_NULL guard between it and the binary comparison case makes the mismatch obvious.
Suggested replacement:
```scala
// MsSqlServer has no boolean type: a comparison expression cannot appear as a value.
// IS NULL/IS NOT NULL over a comparison is rejected so Spark evaluates it locally.
// Binary comparisons themselves are pushed down via inputToSQLNoBool, which rewrites
// any boolean sub-expressions into bit-typed equivalents.
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "milastdbx (via GitHub)" <gi...@apache.org>.
milastdbx commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4611707422
> Thank you for addressing all comments @milastdbx! Waiting for CI.
thanks @uros-b for review. I've added integration tests as well
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4653236720
@milastdbx There are still failures, PTAL:
```
[info] - SPARK-57243: IS [NOT] NULL over a composite operand is pushed down *** FAILED *** (870 milliseconds)
[info] java.lang.ClassCastException: class java.math.BigDecimal cannot be cast to class java.lang.Integer (java.math.BigDecimal and java.lang.Integer are in module java.base of loader 'bootstrap')
```
https://github.com/milastdbx/spark/actions/runs/27147669310/job/80134043671
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243][SQL] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk closed pull request #56296: [SPARK-57243][SQL] Wrap IsNull and IsNotNull in brackets for V2 SQL builder
URL: https://github.com/apache/spark/pull/56296
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243][SQL] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4674915894
The practical backward compatibility: queries that previously threw JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR on SQL Server will now silently succeed (evaluated by Spark). That is an improvement, not a regression. The PR description calling this "No user-facing change" is doubly wrong — not only does the Snowflake case produce new correct results, but the SQL Server case converts a hard error into a correct result.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243][SQL] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "milastdbx (via GitHub)" <gi...@apache.org>.
milastdbx commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4679970780
> Parenthesization is asserted for = (IS NULL + IS NOT NULL) and < (IS NULL only). The remaining five — <>, <=>, <=, >, >= — are untested, as is IS NOT NULL over <.
I can add these, sure - although they might be a bit of an overkill, especially given that these are integration tests.
> Corner case worth a comment: <=> as IS NULL operand.
Worth a test. I agree expression does not make sense, but its not up to data source to decide. Not supporting it can affect braoder pushdowns.
> "We shouldn't propagate these queries" describes the bail-out but contradicts the binary comparison case that follows it. The comment was already imprecise before this PR; placing the new IS_NULL/IS_NOT_NULL guard between it and the binary comparison case makes the mismatch obvious.
This comment sits on top of the whole case block, which also tackles the issue of `PREDICATE_A = PREDICATE_B`.
I will remove we shouldn't push it down and put that we need to special handle it
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243][SQL] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4708320434
+1, LGTM. Merging to master/4.x.
Thank you, @milastdbx and @uros-b @urosstan-db for review.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "urosstan-db (via GitHub)" <gi...@apache.org>.
urosstan-db commented on code in PR #56296:
URL: https://github.com/apache/spark/pull/56296#discussion_r3368273871
##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala:
##########
@@ -272,6 +272,18 @@ class JDBCV2Suite extends SharedSparkSession with ExplainSuiteHelper {
}
}
+ test("SPARK-57243: IS [NOT] NULL over a composite operand is pushed down and runs on H2") {
+ val df1 = sql("SELECT name FROM h2.test.employee WHERE (salary = 10000) IS NOT NULL")
+ checkFiltersRemoved(df1)
+ checkPushedInfo(df1, "PushedFilters: [SALARY IS NOT NULL, (SALARY = 10000.00) IS NOT NULL]")
+ checkAnswer(df1, Seq(Row("amy"), Row("alex"), Row("cathy"), Row("david"), Row("jen")))
Review Comment:
Can you add one row with NULL, since salary is always defined, and we don't know whether all engines would behave same here. It seems we are safe, since (NULL = 10000) should return null on all engines, but just to be sure
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243][SQL] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4675000466
**Test coverage gaps**
The unit test in `JDBCSuite.scala` covers only two of the seven operators recognized by `isBinaryComparisonOperator()`:
- Parenthesization is asserted for `=` (IS NULL + IS NOT NULL) and `<` (IS NULL only). The remaining five — `<>`, `<=>`, `<=`, `>`, `>=` — are untested, as is IS NOT NULL over `<`.
- The MsSqlServer `None`-return assertion only uses `=`. There are no assertions that `(a < b) IS NULL`, `(a <> b) IS NULL`, etc. also fall back to Spark-local evaluation on SQL Server.
Since all seven operators go through the same `isBinaryComparisonOperator()` branch the risk is low, but adding a few extra `assert` lines for e.g. `<>` and `<` on the MsSqlServer path would lock in the invariant.
**Corner case worth a comment: `<=>` as IS NULL operand.**
`<=> ` (null-safe equal) never returns NULL — it always yields TRUE or FALSE. So `(a <=> b) IS NULL` is semantically a constant FALSE. `isBinaryComparisonOperator("<=>") = true`, so it gets parenthesized and pushed down to databases that support it. The generated SQL is valid but the result is trivially empty. This is harmless, but a short note in `isBinaryComparisonOperator()` (or its Javadoc) that `<=>` is included for completeness even though IS NULL over it is always false would help readers.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4669133510
Also, @milastdbx please assign the appropriate component to the PR title, e.g. [SQL]
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4614658148
There are still some failures, PTAL: https://github.com/milastdbx/spark/actions/runs/26891816263/job/79323147609
```
[info] - SPARK-57243: IS [NOT] NULL over a composite operand is pushed down *** FAILED *** (76 milliseconds)
[info] org.apache.spark.SparkException: [JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR.DURING_QUERY_EXECUTION] JDBC external engine syntax error. The error was caused by the query SELECT "name" FROM "employee" WHERE ("salary" IS NOT NULL) AND (("salary" = 10000.00) IS NOT NULL) . Incorrect syntax near the keyword 'IS'. The error occurred during query execution. SQLSTATE: 42000
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "urosstan-db (via GitHub)" <gi...@apache.org>.
urosstan-db commented on code in PR #56296:
URL: https://github.com/apache/spark/pull/56296#discussion_r3368292791
##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala:
##########
@@ -272,6 +272,18 @@ class JDBCV2Suite extends SharedSparkSession with ExplainSuiteHelper {
}
}
+ test("SPARK-57243: IS [NOT] NULL over a composite operand is pushed down and runs on H2") {
+ val df1 = sql("SELECT name FROM h2.test.employee WHERE (salary = 10000) IS NOT NULL")
Review Comment:
Can we add test `(salary + 10000) IS NULL`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #56296:
URL: https://github.com/apache/spark/pull/56296#discussion_r3386308099
##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala:
##########
@@ -100,11 +100,23 @@ private case class MsSqlServerDialect() extends JdbcDialect with NoLegacyJDBCErr
case _ => super.visitSQLFunction(funcName, inputs)
}
+ private def isBinaryComparison(e: Expression): Boolean = e match {
+ case p: Predicate => p.name() match {
+ case "=" | "<>" | "<=>" | "<" | "<=" | ">" | ">=" => true
Review Comment:
The "=", "<>", "<=>", "<", "<=", ">", ">=" set now appears three times (the builder's build, visitIsNullOperand, and MsSqlServerDialect.isBinaryComparison). A shared constant/helper would keep them from drifting.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "urosstan-db (via GitHub)" <gi...@apache.org>.
urosstan-db commented on code in PR #56296:
URL: https://github.com/apache/spark/pull/56296#discussion_r3368262741
##########
connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/MsSqlServerIntegrationSuite.scala:
##########
@@ -94,7 +94,9 @@ class MsSqlServerIntegrationSuite extends DockerJDBCIntegrationV2Suite with V2JD
"scan with aggregate push-down: REGR_SXY with DISTINCT (false)",
"scan with aggregate push-down: REGR_SXY with DISTINCT (true)",
"scan with aggregate push-down: REGR_SXY without DISTINCT (false)",
- "scan with aggregate push-down: REGR_SXY without DISTINCT (true)")
+ "scan with aggregate push-down: REGR_SXY without DISTINCT (true)",
+ // MsSqlServer has no boolean type, so IS [NOT] NULL over a predicate cannot be pushed down.
+ "SPARK-57243: IS [NOT] NULL over a composite operand is pushed down")
Review Comment:
It would be great to not skip test here, since we skip execution of query entirely. Can we introduce variable like "isNotNullOverCompositeOperandPushdownSupported", or even better to check whether resolved dialect is SQL Server since we don't overrides except for sql server
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "milastdbx (via GitHub)" <gi...@apache.org>.
milastdbx commented on PR #56296:
URL: https://github.com/apache/spark/pull/56296#issuecomment-4621437255
> There are still some failures, PTAL: https://github.com/milastdbx/spark/actions/runs/26891816263/job/79323147609
Yes, change turned out to be a bit more involved as SQL Server does not support proposed syntax.
I transitioned to wrapping only binary comparison, for reasons described in the updated description
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57243] Wrap IsNull and IsNotNull in brackets for V2 SQL builder [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #56296:
URL: https://github.com/apache/spark/pull/56296#discussion_r3347670388
##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala:
##########
@@ -272,6 +272,14 @@ class JDBCV2Suite extends SharedSparkSession with ExplainSuiteHelper {
}
}
+ test("SPARK-XXXXX: IS [NOT] NULL over a composite operand is pushed down and runs on H2") {
+ val df = sql("SELECT name FROM h2.test.employee WHERE (salary = bonus) IS NOT NULL")
+ checkFiltersRemoved(df)
+ checkPushedInfo(df, "PushedFilters: [SALARY IS NOT NULL, BONUS IS NOT NULL, " +
+ "(CAST(SALARY AS double) = BONUS) IS NOT NULL]")
+ checkAnswer(df, Seq(Row("amy"), Row("alex"), Row("cathy"), Row("david"), Row("jen")))
Review Comment:
Please fix the indentation according to Scala style guidelines.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org