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_r312946008
##########
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:
If I change the message it will lead to confusion.
for e.g.
User can be able to create database to the location as long as the path does
not exists or it should be empty.
If I say path already exits it will confuse, so I wanted to highlight the
path is not empty
----------------------------------------------------------------
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]