Propagate delete file replication factor for Hadoop parquet files - #255
Open
shanthoosh wants to merge 1 commit into
Open
Propagate delete file replication factor for Hadoop parquet files#255shanthoosh wants to merge 1 commit into
shanthoosh wants to merge 1 commit into
Conversation
…reams ParquetIO's Hadoop shortcut rebuilds a parquet-hadoop OutputFile from just the path and Configuration, which discards the replication factor carried by Iceberg's HadoopOutputFile and opens the stream with the filesystem default replication. Route Hadoop output files with a custom replication factor through the stream-based ParquetOutputFile so the stream is created by Iceberg's HadoopOutputFile with the configured replication. Also stop unwrapping Iceberg's position output stream to the underlying FSDataOutputStream: the abandoned wrapper's finalizer closes the stream mid-write once it is garbage collected. Verified end-to-end through SQL-only Spark 3.5 tests: CREATE TABLE with merge-on-read Parquet, INSERT, DELETE, and the delete_files metadata table, with the catalog warehouse on a capturing filesystem that records the replication factor passed to FileSystem.create. Covers the write.delete-file-replication table property and the spark.sql.iceberg.delete-file-replication session conf set via SQL SET, and verifies data files keep the filesystem default. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Summary
PRs #219 and #229 added support for configuring the replication factor of delete files (
delete-file-replicationwrite option,spark.sql.iceberg.delete-file-replicationsessionconf,write.delete-file-replicationtable property). The configured value is resolved correctly bySparkWriteConfand carried all the way into Iceberg'sHadoopOutputFile, but for Parquet delete files it never reaches HDFS — and Parquet is the default delete file format, so in practice the setting had no effect.Root cause:
ParquetIO.file(...)short-circuits Hadoop-backed output files by rebuilding a parquet-hadoopOutputFilefrom just the path and Configuration:parquet-hadoop then opens the output stream itself via fs.create(path, overwrite, bufferSize, fs.getDefaultReplication(path), blockSize) — using the filesystem default replication and discarding the replication factor carried by the Iceberg HadoopOutputFile. Iceberg's HadoopOutputFile.create(), the only place the configured replication is applied, is never invoked. As a result, merge-on-read DELETE/UPDATE/MERGE always produces Parquet delete files with the cluster default replication regardless of configuration.
Solution
Behavior is unchanged when no replication is configured: the parquet-hadoop shortcut is still used and files inherit the filesystem default.
Testing Done
Unit tests — parquet:TestParquetReplication (new), using a RawLocalFileSystem subclass that records the replication factor passed to every FileSystem.create(...) call:
Integration tests (SQL-only) — spark 3.5:TestParquetDeleteFileReplication (new): the catalog warehouse lives on a capturing filesystem, and the whole flow is driven through SQL —
CREATE TABLE (format-version 2, merge-on-read, Parquet) → INSERT → DELETE →
SELECT file_path FROM t.delete_files:
spark.sql.iceberg.delete-file-replication=7 session conf → delete files created with replication 7 (note: the hyphenated key must be backquoted in Spark SQL SET)