Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/22466#discussion_r226655438 --- Diff: 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) { --- End diff -- if the behavior needs to be consistent over all the external catalog implementations(it should be), then I think putting it here is reasonable. But listing files might be too expensive(e.g. several hourse), is there a better way to check if a directory is empty?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org