cloud-fan commented on a change in pull request #26120: [SPARK-29014][SQL]
DataSourceV2: Fix current/default catalog usage
URL: https://github.com/apache/spark/pull/26120#discussion_r335796374
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala
##########
@@ -481,17 +482,18 @@ final class DataFrameWriter[T] private[sql](ds:
Dataset[T]) {
def saveAsTable(tableName: String): Unit = {
import df.sparkSession.sessionState.analyzer.{AsTableIdentifier,
CatalogObjectIdentifier}
import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
+ import org.apache.spark.sql.connector.catalog.CatalogV2Util._
val session = df.sparkSession
val canUseV2 = lookupV2Provider().isDefined
- val sessionCatalog = session.sessionState.analyzer.sessionCatalog
session.sessionState.sqlParser.parseMultipartIdentifier(tableName) match {
- case CatalogObjectIdentifier(Some(catalog), ident) =>
+ case CatalogObjectIdentifier(catalog, ident) if
!isSessionCatalog(catalog) =>
saveAsTable(catalog.asTableCatalog, ident)
- case CatalogObjectIdentifier(None, ident) if canUseV2 &&
ident.namespace().length <= 1 =>
- saveAsTable(sessionCatalog.asTableCatalog, ident)
+ case CatalogObjectIdentifier(catalog, ident)
+ if isSessionCatalog(catalog) && canUseV2 && ident.namespace().length
<= 1 =>
+ saveAsTable(catalog.asTableCatalog, ident)
Review comment:
It's a known problem that if the v2 session catalog doesn't delegate to v1
session catalog, many things can be broken.
I think the previous version was wrong. It always use the default v2 session
catalog even if users set a custom v2 session catalog.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]