thswlsqls opened a new issue, #17063:
URL: https://github.com/apache/iceberg/issues/17063

   **Apache Iceberg version**
   main @ 035fc1e40
   
   **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()`.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to