manishmalhotrawork commented on a change in pull request #1471:
URL: https://github.com/apache/iceberg/pull/1471#discussion_r490545188
##########
File path:
spark/src/test/java/org/apache/iceberg/actions/TestRemoveOrphanFilesAction.java
##########
@@ -528,6 +566,71 @@ public void testRemoveOrphanFilesWithRelativeFilePath()
throws IOException, Inte
Assert.assertTrue("Invalid file should be present", fs.exists(new
Path(invalidFiles.get(0))));
}
+ @Test
+ public void testRemoveOrphanFilesWithSpecialCharsFilePath() throws
IOException, InterruptedException {
+ File whiteSpaceDir = null;
+ try {
+ whiteSpaceDir = new File(tableDir.getAbsolutePath() + "/white space");
+ whiteSpaceDir.mkdirs();
+
+ Table table = TABLES.create(
+ SCHEMA,
+ PartitionSpec.unpartitioned(),
+ Maps.newHashMap(),
+ tableDir.getAbsolutePath() + "/white space");
+
+ List<ThreeColumnRecord> records = Lists.newArrayList(
+ new ThreeColumnRecord(1, "AAAAAAAAAA", "AAAA")
+ );
+
+ Dataset<Row> df = spark.createDataFrame(records,
ThreeColumnRecord.class).coalesce(1);
+
+ df.select("c1", "c2", "c3")
+ .write()
+ .format("iceberg")
+ .mode("append")
+ .save(whiteSpaceDir.getAbsolutePath());
+
+ List<String> validFiles = spark.read().format("iceberg")
+ .load(whiteSpaceDir + "#files")
+ .select("file_path")
+ .as(Encoders.STRING())
+ .collectAsList();
+ Assert.assertEquals("Should be 1 valid files", 1, validFiles.size());
+ String validFile = validFiles.get(0);
+
+ df.write().mode("append").parquet(whiteSpaceDir + "/data");
+
+ Path dataPath = new Path(whiteSpaceDir + "/data");
+ FileSystem fs =
dataPath.getFileSystem(spark.sessionState().newHadoopConf());
+ List<String> allFiles = Arrays.stream(fs.listStatus(dataPath,
HiddenPathFilter.get()))
+ .filter(FileStatus::isFile)
+ .map(file -> file.getPath().toString())
+ .collect(Collectors.toList());
+ Assert.assertEquals("Should be 2 files", 2, allFiles.size());
+
+ List<String> invalidFiles = Lists.newArrayList(allFiles);
+ invalidFiles.removeIf(file -> file.contains(validFile));
+ Assert.assertEquals("Should be 1 invalid file", 1, invalidFiles.size());
+
+ // sleep for 1 second to unsure files will be old enough
+ Thread.sleep(1000);
+
+ Actions actions = Actions.forTable(table);
+ List<String> result = actions.removeOrphanFiles()
+ .olderThan(System.currentTimeMillis())
+ .execute();
+ Assert.assertEquals("Action should find 1 file", invalidFiles, result);
Review comment:
sure, checked file as well.
----------------------------------------------------------------
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]