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_r312929766
 
 

 ##########
 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 , it means path already exists, I will update the message accordingly

----------------------------------------------------------------
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]

Reply via email to