@@ -710,6 +710,46 @@ def test_upsert_with_nulls(catalog: Catalog) -> None:
710710 schema = schema ,
711711 )
712712
713+ # upsert table with null value
714+ data_with_null = pa .Table .from_pylist (
715+ [
716+ {"foo" : None , "bar" : 1 , "baz" : False },
717+ ],
718+ schema = schema ,
719+ )
720+ upd = table .upsert (data_with_null , join_cols = ["foo" ])
721+ assert upd .rows_updated == 0
722+ assert upd .rows_inserted == 1
723+ assert table .scan ().to_arrow () == pa .Table .from_pylist (
724+ [
725+ {"foo" : None , "bar" : 1 , "baz" : False },
726+ {"foo" : "apple" , "bar" : 7 , "baz" : False },
727+ {"foo" : "banana" , "bar" : None , "baz" : False },
728+ ],
729+ schema = schema ,
730+ )
731+
732+ # upsert table with null and non-null values, in two join columns
733+ data_with_null = pa .Table .from_pylist (
734+ [
735+ {"foo" : None , "bar" : 1 , "baz" : True },
736+ {"foo" : "lemon" , "bar" : None , "baz" : False },
737+ ],
738+ schema = schema ,
739+ )
740+ upd = table .upsert (data_with_null , join_cols = ["foo" , "bar" ])
741+ assert upd .rows_updated == 1
742+ assert upd .rows_inserted == 1
743+ assert table .scan ().to_arrow () == pa .Table .from_pylist (
744+ [
745+ {"foo" : "lemon" , "bar" : None , "baz" : False },
746+ {"foo" : None , "bar" : 1 , "baz" : True },
747+ {"foo" : "apple" , "bar" : 7 , "baz" : False },
748+ {"foo" : "banana" , "bar" : None , "baz" : False },
749+ ],
750+ schema = schema ,
751+ )
752+
713753
714754def test_transaction (catalog : Catalog ) -> None :
715755 """Test the upsert within a Transaction. Make sure that if something fails the entire Transaction is
0 commit comments