aokolnychyi commented on a change in pull request #624: Update SparkTableUtil 
to use SessionCatalog and proper MetricsConfig
URL: https://github.com/apache/incubator-iceberg/pull/624#discussion_r344237368
 
 

 ##########
 File path: spark/src/main/scala/org/apache/iceberg/spark/SparkTableUtil.scala
 ##########
 @@ -352,54 +428,93 @@ object SparkTableUtil {
   }
 
   /**
-   * Import a spark table to a iceberg table.
+   * Import files from an existing Spark table to an Iceberg table.
    *
-   * The import uses the spark session to get table metadata. It assumes no
-   * operation is going on original table and target table and thus is not
+   * The import uses the Spark session to get table metadata. It assumes no
+   * operation is going on the original and target table and thus is not
    * thread-safe.
    *
-   * @param source the database name of the table to be import
-   * @param stagingDir the staging directory to store temporary manifest file
-   * @param table the target table to import
+   * @param spark a Spark session
+   * @param sourceTableIdent an identifier of the source Spark table
+   * @param targetTable an Iceberg table where to import the data
+   * @param stagingDir a staging directory to store temporary manifest files
    */
   def importSparkTable(
-      source: TableIdentifier,
-      stagingDir: String,
-      table: Table): Unit = {
-    val sparkSession = SparkSession.builder().getOrCreate()
-    import sparkSession.sqlContext.implicits._
+      spark: SparkSession,
 
 Review comment:
   I think it is safer to pass an explicit `SparkSession`. In some cases, 
people are using `cloneSession` to have independent SQL confs. In addition, it 
makes it more consistent with the rest of `SparkTableUtil`.

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