Github user maropu commented on a diff in the pull request:
https://github.com/apache/spark/pull/21655#discussion_r198750322
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
---
@@ -1366,4 +1367,18 @@ class SessionCatalog(
// copy over temporary views
tempViews.foreach(kv => target.tempViews.put(kv._1, kv._2))
}
+
+ private def validateLocationOfRename(oldName: TableIdentifier, newName:
TableIdentifier): Unit = {
+ val oldTable = getTableMetadata(oldName)
+ if (oldTable.tableType == CatalogTableType.MANAGED) {
+ val databaseLocation =
+
externalCatalog.getDatabase(oldName.database.getOrElse(currentDb)).locationUri
+ val newTableLocation = new Path(new Path(databaseLocation),
formatTableName(newName.table))
+ val fs = newTableLocation.getFileSystem(hadoopConf)
+ if (fs.exists(newTableLocation)) {
+ throw new AnalysisException(s"Can not rename the managed
table('${oldName}')" +
+ s". The associated location('${newTableLocation.toString}')
already exists.")
--- End diff --
nit: `${newTableLocation.toString}` -> `$newTableLocation`?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]