From 5a29ac2617a53af227248dc4513cb689f3d1b4b4 Mon Sep 17 00:00:00 2001 From: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com> Date: Wed, 5 Aug 2026 20:46:42 +0000 Subject: [PATCH] test(python): cover null keys in merge insert --- python/python/tests/test_table.py | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/python/python/tests/test_table.py b/python/python/tests/test_table.py index 542c944c8..a8a2409e3 100644 --- a/python/python/tests/test_table.py +++ b/python/python/tests/test_table.py @@ -2341,6 +2341,45 @@ def test_merge_insert(mem_db: DBConnection): ) +def test_merge_insert_with_null_on_column(mem_db: DBConnection): + table = mem_db.create_table( + "users", + data=pa.table( + { + "id": [0, 1], + "name": ["Alice", "Bob"], + "record_type": [None, "personal"], + } + ), + ) + new_data = pa.table( + { + "id": [1, 2], + "name": ["Bobby", "Charlie"], + "record_type": ["personal", None], + } + ) + + result = ( + table.merge_insert(["id", "record_type"]) + .when_matched_update_all() + .when_not_matched_insert_all() + .execute(new_data) + ) + + assert result.num_inserted_rows == 1 + assert result.num_updated_rows == 1 + assert result.num_deleted_rows == 0 + expected = pa.table( + { + "id": [0, 1, 2], + "name": ["Alice", "Bobby", "Charlie"], + "record_type": [None, "personal", None], + } + ) + assert table.to_arrow().sort_by("id") == expected + + def test_merge_insert_by_source_delete_expr(mem_db: DBConnection): table = mem_db.create_table( "my_table",