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-34701][SQL] Introduce CommandWithAnalyzedChildren for a command to have its children only analyzed but not optimized #32041

Closed
wants to merge 2 commits into from

Conversation

imback82
Copy link
Contributor

@imback82 imback82 commented Apr 3, 2021

What changes were proposed in this pull request?

Note that this PR proposes an alternate solution to #32032.

This PR proposes to introduce the CommandWithAnalyzedChildren trait such that a command that extends the trait will have its children only analyzed, but not optimized. This can be useful if a logical plan has children where they need to be only analyzed, but not optimized - e.g., CREATE VIEW or CACHE TABLE AS. This also addresses the issue found in #31933.

This PR also updates CreateViewCommand and CacheTableAsSelect to use the new trait such that their children are only analyzed.

Why are the changes needed?

To address the issue where the plan is unnecessarily re-analyzed in CreateViewCommand.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existing tests should cover the changes.

@SparkQA
Copy link

SparkQA commented Apr 3, 2021

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

@SparkQA
Copy link

SparkQA commented Apr 3, 2021

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

@SparkQA
Copy link

SparkQA commented Apr 3, 2021

Test build #136874 has finished for PR 32041 at commit be1c17c.

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

@imback82 imback82 marked this pull request as ready for review April 4, 2021 16:30
trait CommandWithAnalyzedChildren extends Command {
def childrenToAnalyze: Seq[LogicalPlan] = Nil

override final def children: Seq[LogicalPlan] = childrenToAnalyze.filter(!_.analyzed)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit risky. Some analyzer rules may want to transform the child even if it's analyzed.

@imback82
Copy link
Contributor Author

imback82 commented Apr 7, 2021

Closing in favor of #32032.

@imback82 imback82 closed this Apr 7, 2021
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.

3 participants