Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-33036][SQL] Refactor RewriteCorrelatedScalarSubquery code to replace exprIds in a bottom-up manner #29913

Closed

Conversation

maropu
Copy link
Member

@maropu maropu commented Sep 30, 2020

What changes were proposed in this pull request?

This PR intends to refactor code in RewriteCorrelatedScalarSubquery for replacing ExprIds in a bottom-up manner instead of doing in a top-down one.

This PR comes from the talk with @cloud-fan in #29585 (comment).

Why are the changes needed?

To improve code.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing tests.

@SparkQA
Copy link

SparkQA commented Sep 30, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33891/

@SparkQA
Copy link

SparkQA commented Sep 30, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33891/

@SparkQA
Copy link

SparkQA commented Sep 30, 2020

Test build #129274 has finished for PR 29913 at commit 46a227e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member Author

maropu commented Sep 30, 2020

cc: @cloud-fan

@dongjoon-hyun
Copy link
Member

Hi, @maropu .
Could you check the original PR's performance effect? Also, I'm wondering if this PR can recover it.

@cloud-fan
Copy link
Contributor

retest this please

val newExprs = exprs.map { _.transform {
case a: AttributeReference if attrMap.contains(a) =>
val exprId = attrMap.getOrElse(a, a).exprId
a.withExprId(exprId)
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we simply use attrMap(a) or only use the exprId?

Copy link
Member Author

Choose a reason for hiding this comment

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

okay.

@SparkQA
Copy link

SparkQA commented Oct 6, 2020

Test build #129445 has finished for PR 29913 at commit 46a227e.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 6, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34052/

@SparkQA
Copy link

SparkQA commented Oct 6, 2020

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34052/

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34086/

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34086/

@@ -587,6 +589,20 @@ object RewriteCorrelatedScalarSubquery extends Rule[LogicalPlan] {
}
}
}
(newChild, AttributeMap(subqueryAttrMapping))
Copy link
Contributor

Choose a reason for hiding this comment

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

AttributeMap(subqueryAttrMapping.toSeq) to pass scala 2.13 compilation

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I missed that. Updated.

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Test build #129480 has finished for PR 29913 at commit 405be2d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34096/

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34096/

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Test build #129490 has finished for PR 29913 at commit 47ea616.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

attrMap: AttributeMap[Attribute]): Seq[E] = {
if (attrMap.nonEmpty) {
val newExprs = exprs.map { _.transform {
case a: AttributeReference if attrMap.contains(a) => attrMap(a)
Copy link
Contributor

Choose a reason for hiding this comment

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

not a big deal: it's more efficient to write case a: AttributeReference => attrMap.getOrElse(a, a)

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34102/

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34102/

@maropu maropu closed this in 94d648d Oct 7, 2020
@maropu
Copy link
Member Author

maropu commented Oct 7, 2020

GA passed, so merged to master. Thanks, @cloud-fan

@SparkQA
Copy link

SparkQA commented Oct 7, 2020

Test build #129496 has finished for PR 29913 at commit cbd0c5c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants