srowen commented on a change in pull request #22466: [SPARK-25464][SQL] Create
Database to the location,only if it is empty or does not exists.
URL: https://github.com/apache/spark/pull/22466#discussion_r312924860
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
##########
@@ -207,6 +207,14 @@ class SessionCatalog(
"you cannot create a database with this name.")
}
validateName(dbName)
+ // SPARK-25464 fail if DB location exists and is not empty
+ val dbPath = new Path(dbDefinition.locationUri)
+ val fs = dbPath.getFileSystem(hadoopConf)
+ if (!externalCatalog.databaseExists(dbName) && fs.exists(dbPath)
+ && fs.listStatus(dbPath).nonEmpty) {
+ throw new AnalysisException(
+ s"Cannot create database at location $dbPath because the path is not
empty.")
Review comment:
This says 'path not empty' but that suggests 'path is not the empty string'.
This means 'the path exists already' right?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]