ksaiharshavinay opened a new pull request, #4622: URL: https://github.com/apache/iceberg-python/pull/4622
<!-- Closes #4618 --> # Rationale for this change `Table.upsert` treats an unchanged row as updated when a float column holds NaN: `_values_differ` compares with `pc.equal`, where NaN never equals NaN, so re-upserting identical data reports `rows_updated=1` and commits two extra snapshots. Two nulls are already treated as equal; this extends the same treatment to two NaNs for floating-point columns. Each `is_nan` result is filled with `False` first, because `is_nan(null)` is null and would otherwise mask a genuine null-to-NaN change. Thanks to @KartikGupta2007 for the report and the repro script. Scope note: NaN nested inside struct/list/map values still compares through the Python fallback path and counts as changed. That is a separate path from the one reported here, so I left it out of this PR; happy to file it as a follow-up. ## Are these changes tested? Yes. Three new tests in `tests/table/test_upsert.py`, each verified to fail on main and pass with this change: - `test_get_rows_to_update_treats_nans_as_equal` — a NaN-to-NaN row is not returned as an update; a changed row still is. - `test_get_rows_to_update_detects_nan_transitions` — number-to-NaN, NaN-to-number, null-to-NaN and NaN-to-null all still count as updates. - `test_upsert_unchanged_frame_with_nan_row` — the reported scenario end to end: re-upserting the same frame gives `rows_updated=0` and the snapshot count stays at 1. The full `tests/table` unit suite shows the same pass/fail set as on main (the failures there are pre-existing environment issues in my sandbox, unrelated to this change). Lint via the repo's prek hooks (ruff, ruff-format, mypy strict, codespell) passes on both changed files. ## Are there any user-facing changes? Yes — a behavior fix: `upsert` no longer reports updates, or writes new snapshots, for rows whose only "difference" is a NaN in a float column. No API changes. (This looks like it wants the changelog label; I can't add labels myself.) Disclosure: I work with AI assistance and review everything myself before posting. -- 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]
