Skip to content

Upsert counts rows as changed when NaN is nested in a struct/list (Python fallback path) #4623

Backlog
neo-bumblebee-ai/iceberg-python
#1

Description

@ksaiharshavinay

Apache Iceberg version

main (development)

Please describe the bug 🐞

Follow-up to #4618 (fixed for top-level float columns in #4622), as requested by @Fokko in the review there.

_values_differ in pyiceberg/table/upsert_util.py only handles flat columns through the pyarrow compute path. For nested types (struct, list, map) pc.equal raises, so the code falls back to comparing Python lists from to_pylist(), where two distinct float('nan') objects are unequal. A row whose only content is a struct or list containing NaN is therefore reported as changed on every upsert, and the upsert rewrites it and commits new snapshots each time — the same symptom as #4618, through the fallback path.

The same applies to float16 columns: pa.types.is_floating is true for them, but pc.equal may not support float16 and raises, sending them through the same fallback. (Iceberg has no float16 type of its own, so this side is lower priority.)

Expected: a row that is unchanged apart from NaN values nested inside a struct/list should not count as an update, matching the top-level float behavior from #4622. Null handling should stay as it is (null vs NaN is a change, in both directions).

I am happy to work on this as a follow-up PR once the approach is agreed — one option is a NaN-aware comparison for the fallback path that walks nested values.

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

Disclosure: I work with AI assistance and review everything myself before posting.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions