You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org> on 2026/06/02 15:38:16 UTC
[PR] [python] Fix upsert row_id validation failure on tables with row_id holes [paimon]
XiaoHongbo-Hope opened a new pull request, #8092:
URL: https://github.com/apache/paimon/pull/8092
### Purpose
Upsert fails with "Row ID X is out of valid range [0, N)" when the table has non-contiguous row_id ranges caused by partition truncation or reassign operations.
### Tests
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Fix upsert row_id validation failure on tables with row_id holes [paimon]
Posted by "XiaoHongbo-Hope (via GitHub)" <gi...@apache.org>.
XiaoHongbo-Hope commented on code in PR #8092:
URL: https://github.com/apache/paimon/pull/8092#discussion_r3346208186
##########
paimon-python/pypaimon/write/table_update_by_row_id.py:
##########
@@ -109,12 +109,10 @@ def _load_existing_files_info(self) -> _FilesInfo:
else:
entry[1].append(file)
- # Multiple physical files may share the same first_row_id (data evolution);
- # summing row_count per file would over-count logical rows and widen
- # the _ROW_ID validation range incorrectly.
+ # Use max row_id + 1 as upper bound; row_id ranges may have holes.
if row_id_ranges:
merged = Range.sort_and_merge_overlap(row_id_ranges, True, True)
- total_row_count = sum(r.count() for r in merged)
+ total_row_count = max(r.to for r in merged) + 1
Review Comment:
> This fixes the valid high row_id case, but using only `max(row_id) + 1` as the validation bound also makes row IDs in deleted holes look valid. For example, after truncating the first partition the remaining range can be `[3, 4]`; an `update_by_arrow_with_row_id` for `_ROW_ID = 0` now passes the range check, `bisect_right([3], 0) - 1` maps it to `first_row_id = 3`, and `replace_with_mask` ends up with no matching relative index, so the requested update is silently dropped. Could we keep the actual merged `row_id_ranges` in `_FilesInfo` and validate that every input row id belongs to one of those ranges (or otherwise fail) before calculating `_FIRST_ROW_ID`? The upsert path only needs to allow holes between ranges, not accept updates for rows that no longer exist.
Updated
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Fix upsert row_id validation failure on tables with row_id holes [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi closed pull request #8092: [python] Fix upsert row_id validation failure on tables with row_id holes
URL: https://github.com/apache/paimon/pull/8092
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Fix upsert row_id validation failure on tables with row_id holes [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on PR #8092:
URL: https://github.com/apache/paimon/pull/8092#issuecomment-4609494585
Thanks, this addresses my previous concern. Keeping the merged valid row-id ranges and adding the truncate-hole tests looks good to me.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Fix upsert row_id validation failure on tables with row_id holes [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #8092:
URL: https://github.com/apache/paimon/pull/8092
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [python] Fix upsert row_id validation failure on tables with row_id holes [paimon]
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #8092:
URL: https://github.com/apache/paimon/pull/8092#discussion_r3345299565
##########
paimon-python/pypaimon/write/table_update_by_row_id.py:
##########
@@ -109,12 +109,10 @@ def _load_existing_files_info(self) -> _FilesInfo:
else:
entry[1].append(file)
- # Multiple physical files may share the same first_row_id (data evolution);
- # summing row_count per file would over-count logical rows and widen
- # the _ROW_ID validation range incorrectly.
+ # Use max row_id + 1 as upper bound; row_id ranges may have holes.
if row_id_ranges:
merged = Range.sort_and_merge_overlap(row_id_ranges, True, True)
- total_row_count = sum(r.count() for r in merged)
+ total_row_count = max(r.to for r in merged) + 1
Review Comment:
This fixes the valid high row_id case, but using only `max(row_id) + 1` as the validation bound also makes row IDs in deleted holes look valid. For example, after truncating the first partition the remaining range can be `[3, 4]`; an `update_by_arrow_with_row_id` for `_ROW_ID = 0` now passes the range check, `bisect_right([3], 0) - 1` maps it to `first_row_id = 3`, and `replace_with_mask` ends up with no matching relative index, so the requested update is silently dropped. Could we keep the actual merged `row_id_ranges` in `_FilesInfo` and validate that every input row id belongs to one of those ranges (or otherwise fail) before calculating `_FIRST_ROW_ID`? The upsert path only needs to allow holes between ranges, not accept updates for rows that no longer exist.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org