viirya commented on a change in pull request #29885:
URL: https://github.com/apache/spark/pull/29885#discussion_r500652507
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala
##########
@@ -808,9 +808,24 @@ final class DataFrameWriter[T] private[sql](ds:
Dataset[T]) {
assertNotBucketed("jdbc")
// connectionProperties should override settings in extraOptions.
this.extraOptions ++= connectionProperties.asScala
- // explicit url and dbtable should override all
- this.extraOptions ++= Seq("url" -> url, "dbtable" -> table)
- format("jdbc").save()
+ // explicit url should override all
+ this.extraOptions += "url" -> url
+
+ import df.sparkSession.sessionState.analyzer.NonSessionCatalogAndIdentifier
+ import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
+
+ val session = df.sparkSession
+ this.source = "jdbc"
+
+ session.sessionState.sqlParser.parseMultipartIdentifier(table) match {
+ case nameParts @ NonSessionCatalogAndIdentifier(catalog,
tableIdentifier) =>
+ saveAsTable(catalog.asTableCatalog, tableIdentifier, nameParts)
Review comment:
Returned catalog is always a `TableCatalog`?
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala
##########
@@ -808,9 +808,24 @@ final class DataFrameWriter[T] private[sql](ds:
Dataset[T]) {
assertNotBucketed("jdbc")
// connectionProperties should override settings in extraOptions.
this.extraOptions ++= connectionProperties.asScala
- // explicit url and dbtable should override all
- this.extraOptions ++= Seq("url" -> url, "dbtable" -> table)
- format("jdbc").save()
+ // explicit url should override all
+ this.extraOptions += "url" -> url
+
+ import df.sparkSession.sessionState.analyzer.NonSessionCatalogAndIdentifier
+ import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
+
+ val session = df.sparkSession
+ this.source = "jdbc"
+
+ session.sessionState.sqlParser.parseMultipartIdentifier(table) match {
+ case nameParts @ NonSessionCatalogAndIdentifier(catalog,
tableIdentifier) =>
+ saveAsTable(catalog.asTableCatalog, tableIdentifier, nameParts)
Review comment:
Or do we need to check if `catalog` is `JDBCTableCatalog`?
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]