How Can safely delete small files after executed rewriteDataFiles
Query engine
spark 3.2
Question
When I execute the rewriteDataFiles API, the small files are merged into large files. These original small files still exist in the hdfs file. The root user is the merged large file, and the flink user is the original small file.
trino query 'SELECT * FROM "fy_zy_fymx5$files"', the valid file is the file generated by executing the rewriteDataFiles API, the previous small file should be an invalid file
but executed in order rewriteManifests api -->expireSnapshots api -->deleteOrphanFiles api
//expireSnapshots
if (operationMode.equalsIgnoreCase("expireSnapshots")) {
val tsToExpire = System.currentTimeMillis()
SparkActions
.get(spark)
.expireSnapshots(table)
.expireOlderThan(tsToExpire)
.execute()
}
//deleteOrphanFiles
if (operationMode.equalsIgnoreCase("deleteOrphanFiles")) {
val olderThanTimestamp = System.currentTimeMillis
SparkActions
.get(spark)
.deleteOrphanFiles(table)
.olderThan(olderThanTimestamp)
.prefixMismatchMode(PrefixMismatchMode.DELETE)
.execute()
}
//rewriteManifests
if (operationMode.equalsIgnoreCase("rewriteManifests")) {
SparkActions
.get(spark)
.rewriteManifests(table)
.execute()
}
These small files still exist in hdfs and have not been deleted. How Can safely delete small files after executed rewriteDataFiles API?
i ran rewriteDataFiles/compaction from spark , it created big files and left small files. I ran expireSnapShot older than x hours. Then i ran deleteOrphanFiles which have cleaned up all small files and its respective manifest list & manifest files.
try compaction -> expireSnapshots -> deleteOrphanFiles.
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'