Repository navigation
Core: Allow limiting upsert update detection to selected columns - #4454
Open
Anurag-S1ngh wants to merge 1 commit into
Open
Anurag-S1ngh wants to merge 1 commit into
Anurag-S1ngh wants to merge 1 commit into
Conversation
Upsert compared every non-key column to decide whether a matched row changed, which is expensive for wide or nested rows. Add an optional difference_cols argument to get_rows_to_update and both upsert entry points so callers can compare only the columns that signal a change, such as a hash column. The argument is appended to the signatures to keep positional calls working. Unknown columns and key-only selections raise a ValueError.
This branch has not been deployed
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.
Rationale for this change
Upsert compared every non-key column to decide whether a matched row changed. For wide or nested rows this is expensive, and callers often already know which column signals a change, such as a hash column.
Add an optional
difference_colsparameter toTable.upsert,Transaction.upsert, andget_rows_to_update. When set, only those columns are compared. Unknown columns raise aValueError, and the selection must contain at least one non-key column.The parameter is added at the end of the signature to keep positional calls working.
Are these changes tested?
Yes. Unit tests cover comparing only the selected columns, unchanged selected columns, unknown columns, and key-only selections. An end-to-end upsert test confirms that a change in an unselected column does not update the row.
tests/tablepasses.Are there any user-facing changes?
Yes.
upsertaccepts a new optionaldifference_colsargument.