Skip to content

Add support to configure replication factor of delete files. - #219

Merged
shanthoosh merged 10 commits into
openhouse-1.5.2from
configure_replication_during_creation
Jan 7, 2026
Merged

Add support to configure replication factor of delete files.#219
shanthoosh merged 10 commits into
openhouse-1.5.2from
configure_replication_during_creation

Conversation

@shanthoosh

Copy link
Copy Markdown
Collaborator

Changes

Adds support to configures the replication factor during the creation of the delete files. Enables the spark jobs to set the HDFS delete replication as part of the writer configuration.

Tests

  • Added the unit tests for all the introduced changes.
  • Verified that existing FileIO implementations continue to work.
  • ./gradlew clean && ./gradlew build

@shanthoosh
shanthoosh force-pushed the configure_replication_during_creation branch from 19cada3 to 364e96a Compare December 2, 2025 18:11
@shanthoosh
shanthoosh force-pushed the configure_replication_during_creation branch from 07b4998 to 9e078c8 Compare December 2, 2025 21:30
Comment thread api/src/main/java/org/apache/iceberg/io/FileIO.java
Comment thread core/src/main/java/org/apache/iceberg/hadoop/HadoopOutputFile.java Outdated
Comment thread core/src/main/java/org/apache/iceberg/hadoop/HadoopOutputFile.java
Comment thread core/src/main/java/org/apache/iceberg/hadoop/HadoopOutputFile.java
Comment thread core/src/main/java/org/apache/iceberg/hadoop/HadoopOutputFile.java
Comment thread core/src/main/java/org/apache/iceberg/io/OutputFileFactory.java Outdated
Comment thread spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/SparkSQLProperties.java Outdated

@sumedhsakdeo sumedhsakdeo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments.

@shanthoosh
shanthoosh force-pushed the configure_replication_during_creation branch 2 times, most recently from 72ffef6 to 350298a Compare December 9, 2025 23:55
@shanthoosh
shanthoosh force-pushed the configure_replication_during_creation branch 2 times, most recently from 945cd30 to f060270 Compare December 10, 2025 02:10
@shanthoosh
shanthoosh force-pushed the configure_replication_during_creation branch from f060270 to 3eb8f71 Compare December 10, 2025 02:18
Comment thread core/src/main/java/org/apache/iceberg/hadoop/HadoopOutputFile.java Outdated
Comment thread core/src/main/java/org/apache/iceberg/io/OutputFileFactory.java
@shanthoosh
shanthoosh force-pushed the configure_replication_during_creation branch from f5418fb to d3279a5 Compare January 5, 2026 20:55
@shanthoosh
shanthoosh force-pushed the configure_replication_during_creation branch from d3279a5 to 84243fa Compare January 5, 2026 21:04

@sumedhsakdeo sumedhsakdeo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@teamurko teamurko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shanthoosh.

@shanthoosh
shanthoosh merged commit 25f1e5c into openhouse-1.5.2 Jan 7, 2026
24 checks passed
shanthoosh pushed a commit to shanthoosh/iceberg that referenced this pull request Jul 14, 2026
/linkedin#229) into sql-wire-in

# Conflicts:
#	spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/TestSparkWriteConf.java
mkuchenbecker pushed a commit to mkuchenbecker/iceberg that referenced this pull request Jul 21, 2026
…es (v3.5/1.10)

Root cause: the linkedin#219/linkedin#229 delete-file replication override was correctly plumbed
all the way to the delete OutputFileFactory (SparkPositionDeltaWrite threads
deleteFileReplication into the delete factory; OutputFileFactory puts
file-replication-factor into the properties map; HadoopFileIO/HadoopOutputFile
read it). But the actual data/delete file writers BYPASS HadoopOutputFile.create()
(the only place the factor reaches fs.create):

  - Parquet: ParquetIO.file(HadoopOutputFile) returns parquet's native
    HadoopOutputFile.fromPath(path, conf), which opens the file at the file
    system default replication.
  - ORC: ORC.newFileWriter -> OrcFile.createWriter(path, options); ORC's
    PhysicalFsWriter uses fs.getDefaultReplication(path).

So on real HDFS the position-delete files silently took dfs.replication
regardless of the override. This is a pre-existing gap (present in
openhouse-1.5.2 too), only surfaced by real-HDFS validation — the LocalFileSystem
test harness ignores replication entirely.

Fix (guarded by replication > 0, i.e. zero impact when the feature is unused):
  - HadoopOutputFile: expose getReplication().
  - ParquetIO.file(...) both overloads: when a custom replication factor is set,
    route through ParquetOutputFile so iceberg's HadoopOutputFile.create()
    (fs.create with the explicit replication) is used.
  - ORC.newFileWriter: after creating the (empty) writer, apply the requested
    replication to the file via fs.setReplication so the blocks written use it.

Validated on real HDFS (Hadoop 3.2.1, Spark 3.5.2) via the oh-hadoop-spark
docker stack, dfs.replication=3:
  ORC  session delete-file-replication=1        -> delete file %r = 1
  ORC  TBLPROPERTY write.delete-file-replication=2 -> delete file %r = 2
  ORC  UPDATE (MoR) session=1                    -> delete file %r = 1
  Parquet session=1                             -> delete file %r = 1
Data files continue to follow dfs.replication (%r = 3), no regression.

1.10 / Spark-3.5 only; core orc/ and parquet/ modules are shared, so the same
patch should be replayed onto the 1.11 branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LLnVvLYnxjTuH2b5nAHa4A
mkuchenbecker pushed a commit to mkuchenbecker/iceberg that referenced this pull request Jul 22, 2026
…es (v3.5/1.10)

Root cause: the linkedin#219/linkedin#229 delete-file replication override was correctly plumbed
all the way to the delete OutputFileFactory (SparkPositionDeltaWrite threads
deleteFileReplication into the delete factory; OutputFileFactory puts
file-replication-factor into the properties map; HadoopFileIO/HadoopOutputFile
read it). But the actual data/delete file writers BYPASS HadoopOutputFile.create()
(the only place the factor reaches fs.create):

  - Parquet: ParquetIO.file(HadoopOutputFile) returns parquet's native
    HadoopOutputFile.fromPath(path, conf), which opens the file at the file
    system default replication.
  - ORC: ORC.newFileWriter -> OrcFile.createWriter(path, options); ORC's
    PhysicalFsWriter uses fs.getDefaultReplication(path).

So on real HDFS the position-delete files silently took dfs.replication
regardless of the override. This is a pre-existing gap (present in
openhouse-1.5.2 too), only surfaced by real-HDFS validation — the LocalFileSystem
test harness ignores replication entirely.

Fix (guarded by replication > 0, i.e. zero impact when the feature is unused):
  - HadoopOutputFile: expose getReplication().
  - ParquetIO.file(...) both overloads: when a custom replication factor is set,
    route through ParquetOutputFile so iceberg's HadoopOutputFile.create()
    (fs.create with the explicit replication) is used.
  - ORC.newFileWriter: after creating the (empty) writer, apply the requested
    replication to the file via fs.setReplication so the blocks written use it.

Validated on real HDFS (Hadoop 3.2.1, Spark 3.5.2) via the oh-hadoop-spark
docker stack, dfs.replication=3:
  ORC  session delete-file-replication=1        -> delete file %r = 1
  ORC  TBLPROPERTY write.delete-file-replication=2 -> delete file %r = 2
  ORC  UPDATE (MoR) session=1                    -> delete file %r = 1
  Parquet session=1                             -> delete file %r = 1
Data files continue to follow dfs.replication (%r = 3), no regression.

1.10 / Spark-3.5 only; core orc/ and parquet/ modules are shared, so the same
patch should be replayed onto the 1.11 branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LLnVvLYnxjTuH2b5nAHa4A
(cherry picked from commit 06e05cc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants