sandeep-katta 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_r312963310
##########
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:
yes I wanted to describe a case where the path is a directory that exists
but contains files. if the above description is correct then I will update it
----------------------------------------------------------------
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]