Skip to content

dynamic_partition_overwrite by identity(s.x) deletes rows by top-level x #4196

Open

Description

@RyanLin5967

Apache Iceberg version

0.12.0 (latest release)

Please describe the bug 🐞

Currently, dynamic_partition_overwrite builds its delete filter from find_field(source_id).name, which is x for s.x, so it deletes the rows whose top-level x matches and keeps the old rows of the partition it replaces. Without a top-level column of that name it raises ValueError.

import tempfile
import pyarrow as pa
from pyiceberg.catalog.sql import SqlCatalog
from pyiceberg.partitioning import PartitionField, PartitionSpec
from pyiceberg.schema import Schema
from pyiceberg.transforms import IdentityTransform
from pyiceberg.types import LongType, NestedField, StructType

cat = SqlCatalog("c", uri="sqlite:///:memory:", warehouse=f"file://{tempfile.mkdtemp()}")
cat.create_namespace("ns")
schema = Schema(NestedField(1, "x", LongType()), NestedField(2, "s", StructType(NestedField(3, "x", LongType()))))
t = cat.create_table("ns.t", schema=schema, partition_spec=PartitionSpec(PartitionField(3, 1000, IdentityTransform(), "s_x")))
df = lambda *rs: pa.Table.from_pylist([{"x": x, "s": {"x": sx}} for x, sx in rs], schema=schema.as_arrow())
t.append(df((1, 5), (5, 1)))

t.dynamic_partition_overwrite(df((9, 5)))
print(sorted((r["x"], r["s"]["x"]) for r in t.scan().to_arrow().to_pylist()))
# [(1, 5), (9, 5)], should be [(5, 1), (9, 5)]
# rows are (x, s.x): partition s.x = 1 lost its row and s.x = 5 kept its old one

_determine_partitions uses find_column_name for the same field since #2204.

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 30, 2026

    @dragonknightk

    Thanks a lot for the clear report and the reproducible example (´。• ᵕ •。`) I'd like to take this one, and I've opened #4204 with a fix and a regression test based on your example. I'd be really grateful if you could take a look whenever you have a moment. No rush at all, and any feedback is very welcome! (๑•̀ㅂ•́)و✧

  2. RyanLin5967 commented on Oct 31, 2026

    @RyanLin5967
    Author

    Looked at #4204. Switching to find_column_name with the same ValueError matches what _determine_partitions does for this field, and the new test is the repro from this issue, so the diff looks right to me.

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