-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-37929][SQL] Support cascade mode for dropNamespace API
#35246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
0cd7ab1
ff685ed
e72d0c7
56addfb
f0a7f31
fe3a3de
005d0ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import scala.collection.JavaConverters._ | |
| import org.apache.spark.sql.catalyst.analysis.{NamespaceAlreadyExistsException, NoSuchNamespaceException, NoSuchTableException, TableAlreadyExistsException} | ||
| import org.apache.spark.sql.connector.distributions.{Distribution, Distributions} | ||
| import org.apache.spark.sql.connector.expressions.{SortOrder, Transform} | ||
| import org.apache.spark.sql.errors.QueryCompilationErrors | ||
| import org.apache.spark.sql.types.StructType | ||
| import org.apache.spark.sql.util.CaseInsensitiveStringMap | ||
|
|
||
|
|
@@ -213,10 +214,16 @@ class InMemoryTableCatalog extends BasicInMemoryTableCatalog with SupportsNamesp | |
| namespaces.put(namespace.toList, CatalogV2Util.applyNamespaceChanges(metadata, changes)) | ||
| } | ||
|
|
||
| override def dropNamespace(namespace: Array[String]): Boolean = { | ||
| listNamespaces(namespace).foreach(dropNamespace) | ||
| override def dropNamespace(namespace: Array[String], cascade: Boolean): Boolean = { | ||
| listNamespaces(namespace).foreach(namespace => dropNamespace(namespace, cascade)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should only do this if |
||
| try { | ||
| listTables(namespace).foreach(dropTable) | ||
| if (!cascade) { | ||
| if (listTables(namespace).nonEmpty || listNamespaces(namespace).nonEmpty) { | ||
| throw QueryCompilationErrors.cannotDropNonemptyNamespaceError(namespace) | ||
| } | ||
| } else { | ||
| listTables(namespace).foreach(dropTable) | ||
| } | ||
| } catch { | ||
| case _: NoSuchNamespaceException => | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,7 +278,9 @@ class JDBCTableCatalog extends TableCatalog with SupportsNamespaces with Logging | |
| } | ||
| } | ||
|
|
||
| override def dropNamespace(namespace: Array[String]): Boolean = namespace match { | ||
| override def dropNamespace( | ||
| namespace: Array[String], | ||
| cascade: Boolean): Boolean = namespace match { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @beliefer do you know how JDBC support DROP DATABASE CASCADE?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you create a followup PR to fix JDBC source? We need to respect the cascade parameter. thanks!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cloud-fan Thank you for the ping. I will try to fix it. |
||
| case Array(db) if namespaceExists(namespace) => | ||
| if (listTables(Array(db)).nonEmpty) { | ||
| throw QueryExecutionErrors.namespaceNotEmptyError(namespace) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.