cloud-fan commented on a change in pull request #30774:
URL: https://github.com/apache/spark/pull/30774#discussion_r543069288
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
##########
@@ -195,16 +195,21 @@ case class AlterTableRenameCommand(
DDLUtils.verifyAlterTableType(catalog, table, isView)
// If an exception is thrown here we can just assume the table is
uncached;
// this can happen with Hive tables when the underlying catalog is
in-memory.
- val wasCached =
Try(sparkSession.catalog.isCached(oldName.unquotedString)).getOrElse(false)
- if (wasCached) {
+ // If `optStorageLevel` is defined, the old table was cached.
+ val optStorageLevel = Try {
+ val optCachedData =
sparkSession.sharedState.cacheManager.lookupCachedData(
+ sparkSession.table(oldName.unquotedString))
+ optCachedData.map(_.cachedRepresentation.cacheBuilder.storageLevel)
+ }.getOrElse(None)
+ optStorageLevel.foreach { _ =>
Review comment:
nit: `if (optStorageLevel.isDefine)`. It's clearer as a check to see if
the table is cached or not.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]