Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,16 @@ case class DropTableCommand(
case _ =>
}
}
try {
sparkSession.sharedState.cacheManager.uncacheQuery(sparkSession.table(tableName))
} catch {
case _: NoSuchTableException if ifExists =>
case NonFatal(e) => log.warn(e.toString, e)

if (!ifExists || catalog.tableExists(tableName)) {

@cloud-fan cloud-fan Dec 5, 2017

Copy link
Copy Markdown
Contributor

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)
}

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll update soon.

try {
sparkSession.sharedState.cacheManager.uncacheQuery(sparkSession.table(tableName))
} catch {
case NonFatal(e) => log.warn(e.toString, e)
}
catalog.refreshTable(tableName)
catalog.dropTable(tableName, ifExists, purge)
}
catalog.refreshTable(tableName)
catalog.dropTable(tableName, ifExists, purge)
Seq.empty[Row]
}
}
Expand Down