Skip to content

fix(storage): refuse a replace on a partitioned table - #114

Merged
codecapo merged 2 commits into
mainfrom
fix/replace-partitioned
Nov 12, 2026
Merged

codecapo merged 2 commits into
mainfrom
fix/replace-partitioned

Conversation

@codecapo

Copy link
Copy Markdown
Owner

What

replace_if_head refuses a table that has a partition spec, before any
file is written. Follows up #106.

How

prepare_replace checks the table's default partition spec right after
the format version check and refuses it if it has any field. The check
uses the field list rather than is_unpartitioned, because a void field
still widens the partition tuple the manifest writer expects.

Things to know

  • Without the check, the new files carry no partition values
    (write_files builds with none) and write_snapshot writes them
    against the table's spec. iceberg-rust's manifest writer then panics in
    a zip_eq over the two, after the data files are on disk.
  • This is a behaviour fix, so it is kept out of refactor(storage): split lib.rs into append, read and write modules #113, which only moves
    code. Both touch replace.rs in different places; whichever lands
    second gets main merged in.

Tests

  • only_unpartitioned_tables_are_replaced creates a table partitioned
    on id, asks for a replace and checks it is refused with no Parquet
    file written. Without the check it fails with a moved head error
    instead.
  • Workspace line coverage 97.9%.

replace_if_head documents that it works on unpartitioned tables only,
but nothing checked it. On a partitioned table the new files carry no
partition values, and writing the manifest against the table's
partition spec panics in iceberg-rust's manifest writer, whose zip_eq
over the partition values and the spec's fields finds lengths that
differ. By then the data files are already on disk.

prepare_replace now refuses a table whose default partition spec has
any field, before the head check and before any file is written.

Signed-off-by: Mayur Kale <hello@mayurkale.com>
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Table replacement is refused when the table uses a partitioned default specification, preventing replacement files from being written.

prepare_replace now rejects tables whose default partition spec has fields. A regression test verifies the storage error and checks that the attempt writes no Parquet files.

Changes: Replacement guard

Layer / File(s) Summary
Reject partitioned replacements
crates/storage/src/replace.rs
prepare_replace returns a storage error when the default partition spec has fields. The test checks this error and confirms that no Parquet files were written.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • codecapo/infostash#63 — Describes whole-file replacement and excludes partition-scoped overwrites. This change rejects partitioned tables in that replacement path.
  • codecapo/infostash#88 — Describes the same replacement scope. This change enforces that scope for partitioned tables.
  • codecapo/infostash#64 — Describes a full-refresh fallback that uses replace_if_head. This change affects that fallback when its target is partitioned.

Possibly related PRs

  • codecapo/infostash#106 — Adds replace_if_head and its module. This change alters which tables the replacement accepts.
Merge Risk: Minimal · up to 679a1

This change makes replacing a partitioned table fail with a clear error instead of writing files without partition values or panicking in the manifest writer. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: prepare_replace now refuses a replace on a partitioned table. It is in conventional commit form and matches the raw summary and objectives. It is 8 words and 53 charac…
Description check Passed The description states that replace_if_head refuses tables with a partition spec before any file is written. It explains the field-list check, the manifest writer panic it prevents, the related PR #11…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: prepare_replace now refuses a replace on a partitioned table. It is in conventional commit form and matches the raw summary and objectives. It is 8 words and 53 characters, so it is concise.

Full details: Description check

Explanation

The description states that replace_if_head refuses tables with a partition spec before any file is written. It explains the field-list check, the manifest writer panic it prevents, the related PR #113 split, and the new test. It matches the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6a94cfe and 679a15e.

Files selected for processing: 1

  • crates/storage/src/replace.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.04%. Comparing base (6a94cfe) to head (679a15e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #114      +/-   ##
==========================================
+ Coverage   99.03%   99.04%   +0.01%     
==========================================
  Files          16       16              
  Lines        2477     2521      +44     
==========================================
+ Hits         2453     2497      +44     
  Misses         24       24              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecapo
codecapo merged commit 2492912 into main Nov 12, 2026
19 checks passed
@codecapo
codecapo deleted the fix/replace-partitioned branch November 12, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant