pan3793 commented on code in PR #54026:
URL: https://github.com/apache/spark/pull/54026#discussion_r2734947018


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/CreateNamespaceExec.scala:
##########
@@ -37,22 +38,14 @@ case class CreateNamespaceExec(
     private var properties: Map[String, String])
     extends LeafV2CommandExec {
   override protected def run(): Seq[InternalRow] = {
-    import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
-    import org.apache.spark.sql.connector.catalog.SupportsNamespaces._
-
     val ns = namespace.toArray
-    if (!catalog.namespaceExists(ns)) {

Review Comment:
   we don't need this check because `createNamespace` will throw 
`NamespaceAlreadyExistsException` if the namespace already exists, by contract.
   
   
https://github.com/apache/spark/blob/9ce067c7d532a6766d622e55164baa942a065250/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/SupportsNamespaces.java#L121-L131
   
   this also makes it atomic, previously, there are chance that the namespace 
is created by another request between `catalog.namespaceExists` and 
`catalog.createNamespace`, we should delegate it to the Connector to handle 
that.



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

Reply via email to