Skip to content

Core: Fix ShreddedObject.put not clearing prior remove marker #17063

Description

@thswlsqls

Apache Iceberg version
main @ 035fc1e

Query engine
None — engine-agnostic, core variant shredding API

Please describe the bug
ShreddedObject.put(field, value) does not clear a prior remove(field) marker, so after remove() then put() on the same field, get()/fieldNames()/numFields() report the field as missing while writeTo() still serializes it with the new value.
See ShreddedObject.put(String, VariantValue) (core/src/main/java/org/apache/iceberg/variants/ShreddedObject.java line 92-100).
get() short-circuits on removedFields.contains(field) (line 102-106) and nameSet() removes removedFields from the name set (line 64-74); SerializationState builds its field list from shreddedFields, which put() already updated.

Steps to reproduce

  1. ShreddedObject o = new ShreddedObject(metadata)
  2. o.put("a", value1)
  3. o.remove("a")o.get("a") returns null.
  4. o.put("a", value2) — expected: o.get("a") returns value2.
    Actual: o.get("a") still returns null, and o.numFields()/o.fieldNames() exclude "a".
  5. o.writeTo(buffer, 0) — the serialized bytes contain "a" with value2, contradicting step 4.

Additional context
Fix: clear the removedFields marker in put().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions