Skip to content

Conversation

@sunchao
Copy link
Member

@sunchao sunchao commented Feb 3, 2021

What changes were proposed in this pull request?

This PR includes the following changes:

  1. in CatalogImpl.uncacheTable, invalidate caches in cascade when the target table is
    a temp view, and spark.sql.legacy.storeAnalyzedPlanForView is false (default value).
  2. make SessionCatalog.lookupTempView public and return processed temp view plan (i.e., with View op).

Why are the changes needed?

Following SPARK-34052 (#31107), we should invalidate in cascade for CatalogImpl.uncacheTable when the table is a temp view, so that the behavior is consistent.

Does this PR introduce any user-facing change?

Yes, now SQLContext.uncacheTable will drop temp view in cascade by default.

How was this patch tested?

Added a UT

@sunchao sunchao changed the title SPARK-34347 [SPARK-34347][SQL] CatalogImpl.uncacheTable should invalidate in cascade for temp views Feb 3, 2021
@SparkQA
Copy link

SparkQA commented Feb 3, 2021

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

Seq(true, false).foreach { storeAnalyzed =>
withSQLConf(SQLConf.STORE_ANALYZED_PLAN_FOR_VIEW.key -> storeAnalyzed.toString) {
withTempView("view1", "view2") {
sql("CREATE TEMPORARY VIEW view1 AS SELECT * FROM testData WHERE key > 1")
Copy link
Member

Choose a reason for hiding this comment

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

How about GLOBAL TEMPORARY VIEW as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Will add test for that.

@github-actions github-actions bot added the SQL label Feb 3, 2021
@SparkQA
Copy link

SparkQA commented Feb 3, 2021

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

@SparkQA
Copy link

SparkQA commented Feb 3, 2021

Test build #134845 has finished for PR 31462 at commit 865cae9.

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

@SparkQA
Copy link

SparkQA commented Feb 4, 2021

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

Comment on lines +915 to +917
tempViews.get(tableName).map(getTempViewPlan)
} else if (formatDatabaseName(name.database.get) == globalTempViewManager.database) {
globalTempViewManager.get(tableName)
globalTempViewManager.get(tableName).map(getTempViewPlan)
Copy link
Member

Choose a reason for hiding this comment

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

Does this add a View wrapper which is not added previously?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. This is added so we can pass a parsed view plan to CatalogImpl.uncacheView. I think it also fixes a potential issue in refreshTable where refresh is called on TemporaryViewRelation instead of View.

@SparkQA
Copy link

SparkQA commented Feb 4, 2021

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

@SparkQA
Copy link

SparkQA commented Feb 4, 2021

Test build #134858 has finished for PR 31462 at commit 27e8635.

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

@sunchao
Copy link
Member Author

sunchao commented Feb 8, 2021

Any more comments on this @viirya ? cc @dongjoon-hyun too.

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

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

lgtm

@viirya
Copy link
Member

viirya commented Feb 9, 2021

I'll merge this later if no more comments.

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Looks making sense.

cc @linhongliu-db, @cloud-fan and @maryannxue FYI from e02324f and bac50aa

@HyukjinKwon
Copy link
Member

For clarification, it should be fine to merge it (and leave it for them to post-review).

@linhongliu-db
Copy link
Contributor

lgtm

@viirya
Copy link
Member

viirya commented Feb 10, 2021

Thanks! Merging to master.

@viirya viirya closed this in 0986f16 Feb 10, 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.

7 participants