feat: Support difference_cols for upsert update detection#3611
Open
minhduc29 wants to merge 1 commit into
Open
feat: Support difference_cols for upsert update detection#3611minhduc29 wants to merge 1 commit into
minhduc29 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3598
Rationale for this change
upsertcompares every non-key column of each matched row in Python to decide whether it needs updating, which is expensive for wide tables or complex types (structs, lists). This adds an optionaldifference_colsparameter toTable.upsert/Transaction.upsert/get_rows_to_updatethat limits the comparison to a user-provided subset of columns (e.g. a hash column that reflects any change to the row), as proposed in #3598.Design notes:
difference_colsonly affects change detection: rows detected as changed are still written with all of their columns.ValueError, validated up front inTransaction.upsertto fail fast. The issue proposed either raising or falling back to comparing all columns — raising seemed safer, but happy to change if the fallback is preferred.Are these changes tested?
Yes. Unit tests cover detection limited to the listed columns (a matched row changed only outside
difference_colsis skipped), updated rows being written with all columns, the three validation errors, and an end-to-end upsert via the in-memory catalog.Are there any user-facing changes?
Yes, a new optional
difference_colsparameter onTable.upsertandTransaction.upsert, documented in the API docs. No behavior change when it is not provided.