maropu commented on a change in pull request #25699: 
[SPARK-28050][SQL]DataFrameWriter support insertInto a specific table partition
URL: https://github.com/apache/spark/pull/25699#discussion_r321525421
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala
 ##########
 @@ -356,28 +374,39 @@ final class DataFrameWriter[T] private[sql](ds: 
Dataset[T]) {
     val canUseV2 = lookupV2Provider().isDefined
     val sessionCatalogOpt = session.sessionState.analyzer.sessionCatalog
 
+    var parition = Map[String, Option[String]]()
+    if (partionInfo.isDefined) {
+      val res = partionInfo.get.split(",").foreach(partion => {
+        val partionKey = partion.replaceAll("'", "").split("=")(0)
+        val partionValue = partion.replaceAll("'", "").split("=")(1)
+        parition += (partionKey -> Some(partionValue))
+      })
+    }
+
     session.sessionState.sqlParser.parseMultipartIdentifier(tableName) match {
       case CatalogObjectIdentifier(Some(catalog), ident) =>
         insertInto(catalog, ident)
 
       case CatalogObjectIdentifier(None, ident)
-          if canUseV2 && sessionCatalogOpt.isDefined && 
ident.namespace().length <= 1 =>
+        if canUseV2 && sessionCatalogOpt.isDefined && ident.namespace().length 
<= 1 =>
         insertInto(sessionCatalogOpt.get, ident)
 
       case AsTableIdentifier(tableIdentifier) =>
-        insertInto(tableIdentifier)
+        insertInto(tableIdentifier, parition)
       case other =>
         throw new AnalysisException(
           s"Couldn't find a catalog to handle the identifier ${other.quoted}.")
     }
   }
 
+
 
 Review comment:
   nit: remove a blank.

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

Reply via email to