You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/02/02 09:53:50 UTC
[GitHub] [spark] wangyum opened a new pull request #27436:
[SPARK-30705][SQL] Improve CaseWhen sub-expression equality
wangyum opened a new pull request #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436
### What changes were proposed in this pull request?
For CaseWhen, we currently only support the first condition expression. This PR improves this pattern:
```sql
CASE WHEN testUdf(a) > 3 THEN 4
WHEN testUdf(a) = 3 THEN 3
WHEN testUdf(a) = 2 THEN 2
WHEN testUdf(a) = 1 THEN 1
ELSE 0 END
```
### Why are the changes needed?
Improve query performance.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Unit test.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on issue #27436: [SPARK-30705][SQL]
Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581138940
Merged build finished. Test PASSed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on issue #27436: [SPARK-30705][SQL]
Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581119297
Merged build finished. Test PASSed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on issue #27436: [SPARK-30705][SQL]
Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581138941
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/117739/
Test PASSed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on issue #27436:
[SPARK-30705][SQL] Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581119301
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/22500/
Test PASSed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on issue #27436:
[SPARK-30705][SQL] Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581138940
Merged build finished. Test PASSed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on issue #27436: [SPARK-30705][SQL]
Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
SparkQA commented on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581138776
**[Test build #117739 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/117739/testReport)** for PR 27436 at commit [`37ba243`](https://github.com/apache/spark/commit/37ba243320ecf4029dfbd1f9dc4ffdc886770d5c).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] seanli-rallyhealth commented on a change in pull request
#27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
seanli-rallyhealth commented on a change in pull request #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#discussion_r375576876
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala
##########
@@ -91,7 +91,18 @@ class EquivalentExpressions {
def childrenToRecurse: Seq[Expression] = expr match {
case _: CodegenFallback => Nil
case i: If => i.predicate :: Nil
- case c: CaseWhen => c.children.head :: Nil
+ case c: CaseWhen =>
+ val firstExpression = c.children.head
+ val firstUdes = firstExpression.collect { case u: UserDefinedExpression => u }
+ val accessedExpressions = c.children.filter { e =>
+ val udes = e.collect { case u: UserDefinedExpression => u }
+ udes.nonEmpty && firstUdes.containsSlice(udes)
+ }
+ if (accessedExpressions.nonEmpty) {
Review comment:
don't think accessedExpressions will be empty since firstExpression is always inside.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on issue #27436:
[SPARK-30705][SQL] Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581119297
Merged build finished. Test PASSed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on issue #27436: [SPARK-30705][SQL]
Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581119301
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/22500/
Test PASSed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on issue #27436: [SPARK-30705][SQL]
Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
SparkQA commented on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581119203
**[Test build #117739 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/117739/testReport)** for PR 27436 at commit [`37ba243`](https://github.com/apache/spark/commit/37ba243320ecf4029dfbd1f9dc4ffdc886770d5c).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] seanli-rallyhealth commented on a change in pull request
#27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
seanli-rallyhealth commented on a change in pull request #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#discussion_r375581491
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala
##########
@@ -91,7 +91,18 @@ class EquivalentExpressions {
def childrenToRecurse: Seq[Expression] = expr match {
case _: CodegenFallback => Nil
case i: If => i.predicate :: Nil
- case c: CaseWhen => c.children.head :: Nil
+ case c: CaseWhen =>
+ val firstExpression = c.children.head
+ val firstUdes = firstExpression.collect { case u: UserDefinedExpression => u }
+ val accessedExpressions = c.children.filter { e =>
+ val udes = e.collect { case u: UserDefinedExpression => u }
+ udes.nonEmpty && firstUdes.containsSlice(udes)
Review comment:
is this requirement: firstUdes must contains udes on the following expression?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on issue #27436:
[SPARK-30705][SQL] Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581138941
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/117739/
Test PASSed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on issue #27436:
[SPARK-30705][SQL] Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-581119203
**[Test build #117739 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/117739/testReport)** for PR 27436 at commit [`37ba243`](https://github.com/apache/spark/commit/37ba243320ecf4029dfbd1f9dc4ffdc886770d5c).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] maropu commented on issue #27436: [SPARK-30705][SQL]
Improve CaseWhen sub-expression equality
Posted by GitBox <gi...@apache.org>.
maropu commented on issue #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#issuecomment-583918059
Is it worth covering more cases in CaseWhen there? Based on [the code comment](https://github.com/apache/spark/blob/b877aac14657832d1b896ea57e06b0d0fd15ee01/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala#L83-L88), covering more cases could have some overheads to to compute equality of expr trees?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org