Repository navigation
Test add_files duplicate checks on branches - #4347
Open
rahulsmahadev wants to merge 3 commits into
Open
rahulsmahadev wants to merge 3 commits into
rahulsmahadev wants to merge 3 commits into
Conversation
add_files(branch=...) checked duplicates only against the current snapshot, so adding a file to a branch twice committed it again and doubled the rows. The check now also covers the target branch's snapshot, reading shared snapshots and manifests once. Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Author
|
@kevinjqliu @laichunpongben could you take a look when you have a chance? It closes the branch gap in the |
AP24110011695
approved these changes
Nov 11, 2026
AP24110011695
left a comment
Contributor
There was a problem hiding this comment.
Verified locally (Windows, Python 3.12):
- The four new
tests/integration/test_add_files.pybranch tests pass on this branch across all three catalog fixtures (12 passed), and the two rejection tests fail on pre-change code (6 failed with main's source swapped in) — exactly the claimed fail-first behavior. The distinct-file-with-same-rows and referenced-only-by-main tests pass both ways, pinning that legitimate adds stay allowed and the main check is preserved. - Read the diff: the snapshot set dedupes by
snapshot_idand the manifest set bymanifest_path, so shared manifests are scanned once;snapshot_by_name(None)returnsNone(refs.get(None)), so the no-branch path collapses to exactly the old single-snapshot check. The executor/path_filtermachinery is unchanged — the only behavioral delta is the wider candidate set, which matches the description.
Nice find — the inconsistency #3287 describes was easy to hit on branch workflows, and the fix is minimal while keeping the shared-scan cost at one read.
Contributor
Author
|
Gentle ping @kevinjqliu: CI is green and it has one approval. Could you take a look when you have a moment? Thanks! |
Contributor
Author
|
@ebyhr could you take a look when you have a chance? Thanks! |
ebyhr
approved these changes
Nov 16, 2026
Contributor
Author
|
@Fokko could you take a look when you have a chance? It has two approvals and CI is green. Thanks! |
apache#4446 made the duplicate check use the target branch, so the code change is no longer needed. Keep the branch tests as coverage for it, and drop the test for a file referenced only by main, which apache#4446 allows. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
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
#4446 made the
add_filesduplicate check use the target branch, which fixes the case this PR was opened for: adding the same file to a branch twice. Main has no tests for the check on a branch yet, so this PR now only adds them.Are these changes tested?
Yes, this PR only adds tests in
tests/integration/test_add_files.py, run against the memory and SQL catalogs:test_add_files_to_branch_rejects_file_already_referenced_by_branchtest_add_files_to_branch_rejects_file_added_earlier_in_transactiontest_add_files_to_branch_accepts_distinct_file_with_same_rowsThe first two fail when the check reads the current snapshot instead of the branch (the code before #4446) and pass on main.
Are there any user-facing changes?
No.
Related: #3287, #4446
This pull request and its description were written by Isaac.