[SPARK-27924][SQL] Support ANSI SQL Boolean-Predicate syntax #25074
[SPARK-27924][SQL] Support ANSI SQL Boolean-Predicate syntax #25074beliefer wants to merge 30 commits intoapache:masterfrom beliefer:ansi-sql-boolean-test
Conversation
|
Test build #107335 has finished for PR 25074 at commit
|
|
Test build #107430 has finished for PR 25074 at commit
|
|
Retest this please. |
|
@ueshin Could you take a look at this PR? Thanks a lot! |
|
Test build #107449 has finished for PR 25074 at commit
|
|
Test build #107500 has finished for PR 25074 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/booleanExpressions.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/booleanExpressions.scala
Outdated
Show resolved
Hide resolved
|
Retest this please. |
|
Test build #107720 has finished for PR 25074 at commit
|
|
Retest this please. |
|
Test build #107733 has finished for PR 25074 at commit
|
| def isFalse: Predicate = IsFalse(expr) | ||
| def isNotFalse: Predicate = IsNotFalse(expr) | ||
| def isUnknown: Predicate = IsUnknown(expr) | ||
| def isNotUnknown: Predicate = IsNotUnknown(expr) |
There was a problem hiding this comment.
Sorry for adding a comment for the late review rounds, but shall we avoid adding DSL since the whole picture is to support PostgreSQL feature parity? How do you think about that, @maropu ? Can we remove these DSL addition?
There was a problem hiding this comment.
In that case, we should revert this and test("is true | false | unknown expressions").
There was a problem hiding this comment.
I don't have a strong opnion on this though, +1 for your opnion. I don't think all the syntaxes need to be listed up here (It is enough to list up a basic part of them).
There was a problem hiding this comment.
@dongjoon-hyun This is not only a PostgreSQL feature, but a ANSI SQL. I also want to confirm if I really want to delete this and test("is true | false | unknown expressions").
There was a problem hiding this comment.
No, @beliefer . You are confused with Scala DSL and SQL.
This is sql/catalyst/dsl which providing Scala API. This is never ANSI SQL.
SQL Standard doesn't have def isNotUnknown. :)
There was a problem hiding this comment.
No, @beliefer . You are confused with Scala DSL and SQL.
This issql/catalyst/dslwhich providing Scala API. This is never ANSI SQL.
SQL Standard doesn't havedef isNotUnknown. :)
Thanks for your prompt. I am confused indeed and clear now.
|
For the others, this PR looks fine, @beliefer . |
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
Show resolved
Hide resolved
|
Also, I slightly updated the PR description, @beliefer . |
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Please fix #25074 (comment) , @beliefer .
Thanks very much. |
I have reverted that code. |
|
Thank you for updating again, @beliefer . |
|
Test build #108368 has finished for PR 25074 at commit
|
|
Retest this please. |
|
Test build #108373 has finished for PR 25074 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
Outdated
Show resolved
Hide resolved
|
Test build #108435 has finished for PR 25074 at commit
|
|
@dongjoon-hyun @maropu Thanks for all your continuous review and help. |
|
thanks for your hard work! |
| case SqlBaseParser.NULL => | ||
| IsNull(e) | ||
| case SqlBaseParser.TRUE => ctx.NOT match { | ||
| case null => IsTrue(e) |
There was a problem hiding this comment.
isn't it simply EqualNullSafe(e, Literal(true))? Why do we create a bunch of new expressions?
There was a problem hiding this comment.
@cloud-fan It looks more reasonable.
But there exists a different the input expression must be of a boolean type. The input of EqualNullSafe is any DataType.
Do I need to adjust? cc @dongjoon-hyun @maropu
There was a problem hiding this comment.
EqualNullSafe requires the left type to be the same as right type, so EqualNullSafe(e, Literal(true)) requires e to be boolean.
IsNull is a problem so I think that change makes sense.
There was a problem hiding this comment.
Ah, I missed that approach and the @cloud-fan one sounds more reasonable. If @dongjoon-hyun is not against the idea, can you make a PR for that? @beliefer
There was a problem hiding this comment.
@cloud-fan @maropu Let's wait @dongjoon-hyun , then I will make a PR.
There was a problem hiding this comment.
Sorry for being late. +1 for that approach.
There was a problem hiding this comment.
Thanks for the check, @dongjoon-hyun ! Plz go ahead, @beliefer
### What changes were proposed in this pull request? This PR follows #25074 and improves the implement. ### Why are the changes needed? Improve code. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Exists UT Closes #27699 from beliefer/improve-boolean-test. Authored-by: beliefer <beliefer@163.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
### What changes were proposed in this pull request? This PR follows #25074 and improves the implement. ### Why are the changes needed? Improve code. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Exists UT Closes #27699 from beliefer/improve-boolean-test. Authored-by: beliefer <beliefer@163.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 1515d45) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
### What changes were proposed in this pull request? This PR follows apache#25074 and improves the implement. ### Why are the changes needed? Improve code. ### Does this PR introduce any user-facing change? No ### How was this patch tested? Exists UT Closes apache#27699 from beliefer/improve-boolean-test. Authored-by: beliefer <beliefer@163.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
This PR aims to support ANSI SQL
Boolean-Predicatesyntax.There are some mainstream database support this syntax.
For example:
Note: A null input is treated as the logical value "unknown".
How was this patch tested?
Pass the Jenkins with the newly added test cases.