feat: add support for filter during merge insert when matched (#948)

Closes #940
This commit is contained in:
Weston Pace
2024-02-09 10:26:14 -08:00
committed by GitHub
parent 48d55bf952
commit a9727eb318
12 changed files with 150 additions and 51 deletions

View File

@@ -513,8 +513,15 @@ def test_merge_insert(db):
).when_matched_update_all().when_not_matched_insert_all().execute(new_data)
expected = pa.table({"a": [1, 2, 3, 4], "b": ["a", "x", "y", "z"]})
# These `sort_by` calls can be removed once lance#1892
# is merged (it fixes the ordering)
assert table.to_arrow().sort_by("a") == expected
table.restore(version)
# conditional update
table.merge_insert("a").when_matched_update_all(where="target.b = 'b'").execute(
new_data
)
expected = pa.table({"a": [1, 2, 3], "b": ["a", "x", "c"]})
assert table.to_arrow().sort_by("a") == expected
table.restore(version)