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][FOLLOW-UP] Children/innerChildren should be mutually exclusive for AnalysisOnlyCommand #32447

Closed
wants to merge 2 commits into from

Conversation

imback82
Copy link
Contributor

@imback82 imback82 commented May 6, 2021

What changes were proposed in this pull request?

This is a follow up to #32032 (comment). Basically, children/innerChildren should be mutually exclusive for AlterViewAsCommand and CreateViewCommand, which extend AnalysisOnlyCommand. Otherwise, there could be an issue in the EXPLAIN command. Currently, this is not an issue, because these commands will be analyzed (children will always be empty) when the EXPLAIN command is run.

Why are the changes needed?

To be future-proof where these commands are directly used.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added new tsts

@github-actions github-actions bot added the SQL label May 6, 2021
@SparkQA
Copy link

SparkQA commented May 6, 2021

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

@SparkQA
Copy link

SparkQA commented May 6, 2021

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

@imback82
Copy link
Contributor Author

imback82 commented May 6, 2021

cc @cloud-fan

@SparkQA
Copy link

SparkQA commented May 6, 2021

Test build #138185 has finished for PR 32447 at commit 2e8253d.

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

@@ -46,5 +47,6 @@ trait AnalysisOnlyCommand extends Command {
val isAnalyzed: Boolean
def childrenToAnalyze: Seq[LogicalPlan]
override final def children: Seq[LogicalPlan] = if (isAnalyzed) Nil else childrenToAnalyze
override def innerChildren: Seq[QueryPlan[_]] = if (isAnalyzed) childrenToAnalyze else Nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cloud-fan, updated. Do you also want to explicitly override this to be Nil for CacheTable, CacheTableAsSelect and UncacheTable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it have real impact in EXPLAIN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a change, but I think it's for better:
Before:

== Parsed Logical Plan ==
'CacheTableAsSelect tempTable, SELECT key FROM testData, false, false
+- 'Project ['key]
   +- 'UnresolvedRelation [testData], [], false

== Analyzed Logical Plan ==
CacheTableAsSelect tempTable, Project [key#13], SELECT key FROM testData, false, true

== Optimized Logical Plan ==
CacheTableAsSelect tempTable, Project [key#13], SELECT key FROM testData, false, true

== Physical Plan ==
CacheTableAsSelect tempTable, Project [key#13], SELECT key FROM testData, false

New:

== Parsed Logical Plan ==
'CacheTableAsSelect tempTable, SELECT key FROM testData, false, false
+- 'Project ['key]
   +- 'UnresolvedRelation [testData], [], false

== Analyzed Logical Plan ==
CacheTableAsSelect tempTable, SELECT key FROM testData, false, true
   +- Project [key#13]
      +- SubqueryAlias testdata
         +- View (`testData`, [key#13,value#14])
            +- SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).key AS key#13, staticinvoke(class org.apache.spark.unsafe.types.UTF8String, StringType, fromString, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).value, true, false) AS value#14]
               +- ExternalRDD [obj#12]

== Optimized Logical Plan ==
CacheTableAsSelect tempTable, SELECT key FROM testData, false, true
   +- Project [key#13]
      +- SubqueryAlias testdata
         +- View (`testData`, [key#13,value#14])
            +- SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).key AS key#13, staticinvoke(class org.apache.spark.unsafe.types.UTF8String, StringType, fromString, knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).value, true, false) AS value#14]
               +- ExternalRDD [obj#12]

== Physical Plan ==
CacheTableAsSelect tempTable, Project [key#13], SELECT key FROM testData, false

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And we can improve the EXPLAIN for physical plans as well as a future PR if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

yea looks better!

@SparkQA
Copy link

SparkQA commented May 6, 2021

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

@SparkQA
Copy link

SparkQA commented May 6, 2021

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

@imback82 imback82 changed the title [SPARK-34701][SQL][FOLLOW-UP] Children/innerChildren should be mutually exclusive for AlterViewAsCommand/CreateViewCommand [SPARK-34701][SQL][FOLLOW-UP] Children/innerChildren should be mutually exclusive for AnalysisOnlyCommand May 6, 2021
@SparkQA
Copy link

SparkQA commented May 6, 2021

Test build #138217 has finished for PR 32447 at commit abf39b7.

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

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 33c1034 May 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