Skip to content

Appending to a branch that does not exist creates it without main's rows #4195

Open

Description

@RyanLin5967

Apache Iceberg version

0.12.0 (latest release)

Please describe the bug 🐞

Currently, a write to a missing branch takes no parent, so the new branch holds only the rows just written. Creating the branch with create_branch first gives [1, 2, 3].

import tempfile
import pyarrow as pa
from pyiceberg.catalog.sql import SqlCatalog

cat = SqlCatalog("c", uri="sqlite:///:memory:", warehouse=f"file://{tempfile.mkdtemp()}")
cat.create_namespace("ns")
t = cat.create_table("ns.t", schema=pa.schema([("x", pa.int64())]))
t.append(pa.table({"x": [1, 2]}))

t.append(pa.table({"x": [3]}), branch="b")
print(t.scan().use_ref("b").to_arrow()["x"].to_pylist())
# [3], should be [1, 2, 3]
# Java's SnapshotUtil.latestSnapshot takes the current snapshot as the parent of a missing branch
print(t.snapshot_by_name("b").parent_snapshot_id)
# None

overwrite does the same, and so does a retried append after a concurrent remove_branch.

tested on pyiceberg 0.12.0 and main

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Activity

  1. dragonknightk commented on Oct 31, 2026

    @dragonknightk

    Thanks for the report! I've opened #4217 for this and I'm taking it (´。• ᵕ •。`) Writes to a missing branch now start from main's current snapshot, like Java ʕ•ᴥ•ʔ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions