szehon-ho commented on a change in pull request #2779:
URL: https://github.com/apache/iceberg/pull/2779#discussion_r671591451



##########
File path: spark/src/main/java/org/apache/iceberg/spark/SparkTableUtil.java
##########
@@ -425,6 +455,21 @@ private static void 
importUnpartitionedSparkTable(SparkSession spark, TableIdent
       List<DataFile> files = TableMigrationUtil.listPartition(
           partition, Util.uriToString(sourceTable.location()), format.get(), 
spec, conf, metricsConfig, nameMapping);
 
+      if (checkDuplicateFiles) {
+        Dataset<Row> fileDs = spark.createDataset(
+            Lists.transform(files, f -> f.path().toString()), 
Encoders.STRING())
+            .toDF("file_path");
+
+        Dataset<Row> existingFiles = loadMetadataTable(spark, targetTable, 
MetadataTableType.ENTRIES);
+        Column joinCond = 
existingFiles.col("data_file.file_path").equalTo(fileDs.col("file_path"));
+        Dataset<Row> duplicates = fileDs.join(existingFiles, joinCond);
+        List<String> duplicateList = Arrays.stream((Row[]) duplicates.head(10))

Review comment:
       Yea and before it was doing 'duplicates.select("file_path").head(10)' 
and still failed, I think the pruning issue got worse in Spark 3.1 (wrote some 
test in #2783)  (Or was there another select you had in mind?)




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to