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-18169][SQL] Suppress warnings when dropping views on a dropped table #15682

Closed
wants to merge 1 commit into from
Closed

[SPARK-18169][SQL] Suppress warnings when dropping views on a dropped table #15682

wants to merge 1 commit into from

Conversation

dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Oct 29, 2016

What changes were proposed in this pull request?

Apache Spark 2.x shows an AnalysisException warning message when dropping a view on a dropped table. This does not happen on dropping temporary views. Also, Spark 1.6.x does not show warnings. We had better suppress this to be more consistent in Spark 2.x and with Spark 1.6.x.

scala> sql("create table t(a int)")

scala> sql("create view v as select * from t")

scala> sql("create temporary view tv as select * from t")

scala> sql("drop table t")

scala> sql("drop view tv")

scala> sql("drop view v")
16/10/29 15:50:03 WARN DropTableCommand: org.apache.spark.sql.AnalysisException: Table or view not found: `default`.`t`; line 1 pos 91;
'SubqueryAlias v, `default`.`v`
+- 'Project ['gen_attr_0 AS a#19]
   +- 'SubqueryAlias t
      +- 'Project ['gen_attr_0]
         +- 'SubqueryAlias gen_subquery_0
            +- 'Project ['a AS gen_attr_0#18]
               +- 'UnresolvedRelation `default`.`t`

org.apache.spark.sql.AnalysisException: Table or view not found: `default`.`t`; line 1 pos 91;
'SubqueryAlias v, `default`.`v`
+- 'Project ['gen_attr_0 AS a#19]
   +- 'SubqueryAlias t
      +- 'Project ['gen_attr_0]
         +- 'SubqueryAlias gen_subquery_0
            +- 'Project ['a AS gen_attr_0#18]
               +- 'UnresolvedRelation `default`.`t`
...
res5: org.apache.spark.sql.DataFrame = []

Note that this is different case of dropping non-exist views. For those cases, Spark raises NoSuchTableException.

How was this patch tested?

Manual because this is a suppression of warning message.

@SparkQA
Copy link

SparkQA commented Oct 30, 2016

Test build #67775 has finished for PR 15682 at commit 9145c60.

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

@SparkQA
Copy link

SparkQA commented Nov 10, 2016

Test build #68449 has finished for PR 15682 at commit fef9981.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

Retest this please.

@SparkQA
Copy link

SparkQA commented Nov 10, 2016

Test build #68453 has finished for PR 15682 at commit fef9981.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

Hmm. randomized aggregation test fails consistently.

- randomized aggregation test - [typed, with distinct] - with grouping keys - with non-empty input

@dongjoon-hyun
Copy link
Member Author

Retest this please

@SparkQA
Copy link

SparkQA commented Nov 10, 2016

Test build #68479 has finished for PR 15682 at commit fef9981.

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

@dongjoon-hyun
Copy link
Member Author

Retest this please.

@SparkQA
Copy link

SparkQA commented Nov 14, 2016

Test build #68635 has finished for PR 15682 at commit fef9981.

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

@dongjoon-hyun
Copy link
Member Author

Hi, @gatorsmile .
How do you think about this PR? I can close this if you don't feel strongly.

@@ -202,6 +202,7 @@ case class DropTableCommand(
sparkSession.sharedState.cacheManager.uncacheQuery(
sparkSession.table(tableName.quotedString))
} catch {
case ae: AnalysisException if ae.getMessage.contains("Table or view not found") =>
Copy link
Member

Choose a reason for hiding this comment

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

Is it NoSuchTableException?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for review, @gatorsmile .
It's originally NoSuchTableException, but Analyzer changed into this at here.
So, the catch expression becomes ugly.

Copy link
Member Author

Choose a reason for hiding this comment

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

May I fix that to throw the original exception? NoSuchTableException extends AnalysisException and has more context like database name. Oops, Sorry. We cannot. The current AnalysisException has the line number and start position.

@gatorsmile
Copy link
Member

gatorsmile commented Nov 16, 2016

Based on my understanding, when we try to drop a view, we look up and analyze the view and then issue an exception if any involved table has been dropped. We might have a bug here.

That means, we will not call uncacheQuery, if any involved table is dropped before dropping the view. It is a bug, right?

@dongjoon-hyun
Copy link
Member Author

Sorry, but uncacheQuery is related to this PR?

@dongjoon-hyun
Copy link
Member Author

Ah, you mean that code you gave the pointer.

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Nov 16, 2016

Yep. uncachedQuery is not called here. Yep. I got it. It's a bug. I'll fix that. Thank you, @gatorsmile !

@gatorsmile
Copy link
Member

This case is more complicated. Please try to check whether there is a bug. If yes, please fix it in this PR. Suppress warnings might be easily fixed when you fix this bug.

@dongjoon-hyun
Copy link
Member Author

Yep. I investigate the behavior here.

@gatorsmile
Copy link
Member

gatorsmile commented Nov 16, 2016

Thank you!

I think the PR #15896 is fixing a related issue in override def uncacheTable(tableName: String). The fixed behavior needs to be consistent with each other.

TruncateTableCommand has the same issue. We need to suppress the warnings too

@dongjoon-hyun
Copy link
Member Author

I see. I'll include that command here, too.

@gatorsmile
Copy link
Member

Please follw the ongoing design decision changes in Spark-18465

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Nov 16, 2016

Sure! I'm watching that PR now. I'll wait for a while.

@dongjoon-hyun
Copy link
Member Author

Hi, @gatorsmile .
Is there any decision for the following?

The fixed behavior needs to be consistent with each other.

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Nov 19, 2016

If the issue (and bugs) about uncacheQuery and uncacheTable is postpone, I'd like to focus on the warning messages in this PR. Is it okay? We can revisit that uncache cases for Apache Spark 2.2.

For TruncateTableCommand command, it's not allowed for view. So, it seems not to be related with dropped table case, here. I couldn't reproduce that.

@gatorsmile
Copy link
Member

We should not suppress the warnings. Instead, we should improve the error message to show the unache attempt failed, right?

@hvanhovell
Copy link
Contributor

@dongjoon-hyun @gatorsmile I totally missed this one. Shall we try to get this in 2.1?

@gatorsmile
Copy link
Member

The warning message is valid. We might need to issue a better exception here.

To resolve the root cause, we might need adding a new API for uncaching the view in which a relevant table has been dropped? I am not confident how to do it in a perfect way. Let me open a JIRA now and cc both of you in the discussion.

@dongjoon-hyun
Copy link
Member Author

Thank you for coming back, @gatorsmile and @hvanhovell !

@gatorsmile
Copy link
Member

A JIRA is created: https://issues.apache.org/jira/browse/SPARK-18549

@dongjoon-hyun
Copy link
Member Author

Ah, In fact, that issue includes this. May I close this PR and the issue SPARK-18169 ?

@gatorsmile
Copy link
Member

Sure, maybe close it now. If we are unable to contain it in Spark 2.1, we can continue this work to issue a better error message.

@dongjoon-hyun
Copy link
Member Author

I guess SPARK-18169 will cover the better error message too. That issue will need to revisit all occurrence of uncache and related exception handling. Thank you, @gatorsmile and @hvanhovell . I close this in favor of SPARK-18549 .

@dongjoon-hyun dongjoon-hyun deleted the SPARK-18169 branch January 7, 2019 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants