Repository navigation
Core: Compare upsert rows column by column instead of cell by cell - #4334
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
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
get_rows_to_updatecompared every matched row one cell at a time, slicing both tables and callingas_py()for each column. Cost grew with rows times columns: on a table with 200 columns and 20k matched rows the comparison alone took around 20 seconds, before anything was written.The matched rows are now gathered once and compared column by column with PyArrow kernels. Two nulls count as equal, a null against a value counts as a change, and every row is still returned only once. Columns whose types have no comparison kernel, structs and lists today, fall back to the previous value-by-value comparison, so nested types behave as before.
The reproduction from the issue now takes about 0.1 seconds instead of about 20.
Are these changes tested?
Yes. New tests in
tests/table/test_upsert.pycoverget_rows_to_updatedirectly:Full unit suite:
4570 passed, 5 skipped.prek run -apasses.Are there any user-facing changes?
Yes, only in speed:
upsertno longer slows down sharply with the number of columns. The returned rows are unchanged, except that two NaN values in the same column now compare equal, which matches Iceberg's comparator semantics.Closes #3860