-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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-22686][SQL] DROP TABLE IF EXISTS should not show AnalysisException #19888
Conversation
@@ -206,7 +206,8 @@ case class DropTableCommand( | |||
try { | |||
sparkSession.sharedState.cacheManager.uncacheQuery(sparkSession.table(tableName)) | |||
} catch { | |||
case _: NoSuchTableException if ifExists => | |||
case ae: AnalysisException | |||
if ifExists && ae.cause.nonEmpty && ae.getCause.isInstanceOf[NoSuchTableException] => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scala> spark.version
res2: String = 2.3.0-SNAPSHOT
scala> sql("DROP TABLE IF EXISTS t")
res3: org.apache.spark.sql.DataFrame = []
scala> sql("DROP TABLE IF EXISTS t")
res4: org.apache.spark.sql.DataFrame = []
Unable to reproduce it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's in the log, which means it's not a serious bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see it in 2.2.1. It is a warning message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, it's fixed in master?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dongjoon-hyun can you verify it? thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can reproduce it in master now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. It exists in master, too.
I'll update like the example by @cloud-fan .
Test build #84454 has finished for PR 19888 at commit
|
Test build #84458 has finished for PR 19888 at commit
|
Retest this please. |
case _: NoSuchTableException if ifExists => | ||
case NonFatal(e) => log.warn(e.toString, e) | ||
|
||
if (!ifExists || catalog.tableExists(tableName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it's more readable to write
if (catalog.tableExists(tableName)) {
... do the drop
} else if (ifExists) {
// do nothing
} else {
log.warn("The table to drop does not exist: " +tableName)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also update the UNCACHE TABLE, cc @gatorsmile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update soon.
Test build #84463 has finished for PR 19888 at commit
|
I added a VIEW case and we need to throw |
LGTM pending Jenkins |
Thank you, @gatorsmile . |
Test build #84495 has finished for PR 19888 at commit
|
thanks, merging to master/2.2! |
…tion ## What changes were proposed in this pull request? During [SPARK-22488](#19713) to fix view resolution issue, there occurs a regression at `2.2.1` and `master` branch like the following. This PR fixes that. ```scala scala> spark.version res2: String = 2.2.1 scala> sql("DROP TABLE IF EXISTS t").show 17/12/04 21:01:06 WARN DropTableCommand: org.apache.spark.sql.AnalysisException: Table or view not found: t; org.apache.spark.sql.AnalysisException: Table or view not found: t; ``` ## How was this patch tested? Manual. Author: Dongjoon Hyun <dongjoon@apache.org> Closes #19888 from dongjoon-hyun/SPARK-22686. (cherry picked from commit 82183f7) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Thank you, @cloud-fan and @gatorsmile ! |
…tion ## What changes were proposed in this pull request? During [SPARK-22488](apache#19713) to fix view resolution issue, there occurs a regression at `2.2.1` and `master` branch like the following. This PR fixes that. ```scala scala> spark.version res2: String = 2.2.1 scala> sql("DROP TABLE IF EXISTS t").show 17/12/04 21:01:06 WARN DropTableCommand: org.apache.spark.sql.AnalysisException: Table or view not found: t; org.apache.spark.sql.AnalysisException: Table or view not found: t; ``` ## How was this patch tested? Manual. Author: Dongjoon Hyun <dongjoon@apache.org> Closes apache#19888 from dongjoon-hyun/SPARK-22686. (cherry picked from commit 82183f7) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
During SPARK-22488 to fix view resolution issue, there occurs a regression at
2.2.1
andmaster
branch like the following. This PR fixes that.How was this patch tested?
Manual.