This is an automated email from the ASF dual-hosted git repository.

wenchen pushed a commit to branch branch-3.4
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.4 by this push:
     new 9b6b66df9e6 [SPARK-42600][SQL] CatalogImpl.currentDatabase shall use 
NamespaceHelper instead of MultipartIdentifierHelper
9b6b66df9e6 is described below

commit 9b6b66df9e6c8bc261243b53cf145f1881e0c013
Author: Kent Yao <y...@apache.org>
AuthorDate: Tue Feb 28 09:57:52 2023 +0800

    [SPARK-42600][SQL] CatalogImpl.currentDatabase shall use NamespaceHelper 
instead of MultipartIdentifierHelper
    
    ### What changes were proposed in this pull request?
    
    v2 catalog default namespace may be empty
    
    ```java
    Exception in thread "main" org.apache.spark.sql.AnalysisException: 
Multi-part identifier cannot be empty.
            at 
org.apache.spark.sql.errors.QueryCompilationErrors$.emptyMultipartIdentifierError(QueryCompilationErrors.scala:1887)
            at 
org.apache.spark.sql.connector.catalog.CatalogV2Implicits$MultipartIdentifierHelper.<init>(CatalogV2Implicits.scala:152)
            at 
org.apache.spark.sql.connector.catalog.CatalogV2Implicits$.MultipartIdentifierHelper(CatalogV2Implicits.scala:150)
            at 
org.apache.spark.sql.internal.CatalogImpl.currentDatabase(CatalogImpl.scala:65)
    ```
    
    ### Why are the changes needed?
    
    bugfix
    
    ### Does this PR introduce _any_ user-facing change?
    
    no
    
    ### How was this patch tested?
    
    locally verified
    
    Closes #40192 from yaooqinn/SPARK-42600.
    
    Authored-by: Kent Yao <y...@apache.org>
    Signed-off-by: Wenchen Fan <wenc...@databricks.com>
    (cherry picked from commit 53c4158386aaa6278a2e428f6ab11eaf71e740d2)
    Signed-off-by: Wenchen Fan <wenc...@databricks.com>
---
 .../src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala
index 79b0084da23..f962edc8858 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala
@@ -28,7 +28,7 @@ import org.apache.spark.sql.catalyst.catalog._
 import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
 import org.apache.spark.sql.catalyst.plans.logical.{CreateTable, 
LocalRelation, LogicalPlan, RecoverPartitions, ShowFunctions, ShowNamespaces, 
ShowTables, TableSpec, View}
 import org.apache.spark.sql.connector.catalog.{CatalogManager, CatalogPlugin, 
CatalogV2Util, FunctionCatalog, Identifier, SupportsNamespaces, Table => 
V2Table, TableCatalog, V1Table}
-import 
org.apache.spark.sql.connector.catalog.CatalogV2Implicits.{CatalogHelper, 
MultipartIdentifierHelper, TransformHelper}
+import 
org.apache.spark.sql.connector.catalog.CatalogV2Implicits.{CatalogHelper, 
MultipartIdentifierHelper, NamespaceHelper, TransformHelper}
 import org.apache.spark.sql.errors.QueryCompilationErrors
 import org.apache.spark.sql.execution.command.ShowTablesCommand
 import org.apache.spark.sql.execution.datasources.{DataSource, LogicalRelation}
@@ -62,7 +62,7 @@ class CatalogImpl(sparkSession: SparkSession) extends Catalog 
{
    * Returns the current default database in this session.
    */
   override def currentDatabase: String =
-    sparkSession.sessionState.catalogManager.currentNamespace.toSeq.quoted
+    sparkSession.sessionState.catalogManager.currentNamespace.quoted
 
   /**
    * Sets the current default database in this session.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to