cloud-fan commented on a change in pull request #35202:
URL: https://github.com/apache/spark/pull/35202#discussion_r784463563
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DropNamespaceExec.scala
##########
@@ -46,9 +46,17 @@ case class DropNamespaceExec(
}
}
- if (!nsCatalog.dropNamespace(ns)) {
- throw
QueryCompilationErrors.cannotDropNonemptyNamespaceError(namespace)
+ nsCatalog match {
+ case v2SessionCatalog: V2SessionCatalog =>
+ if (!v2SessionCatalog.dropNamespaceWithCascadeMode(ns, cascade)) {
Review comment:
I think the problem here is how to fail quickly if the namespace is not
empty and the cascade is not specified. The current implementation is quite
slow because it does a `listTables`. What's worse, it does not check if the
database has functions or not.
We can certainly special-case Hive here and call its `dropDatabase` method
with the cascade parameter. But this exposes a limitation in the API, that the
implementations can't implement `dropNamespace` well.
One option is to add a new API `isNamespaceEmpty`, so that we can simply
call this API and fail immediately. However, Hive Metastore can't implement
this API efficiently.
My proposal is to add a new API `dropNamespace(String[] ns, boolean
cascade)` to replace the API, and ask the implementation to deal with the
cascade parameter by itself.
cc @imback82 @huaxingao @MaxGekk
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]