@@ -734,6 +734,7 @@ def test_transaction(catalog: Catalog) -> None:
734
734
assert df_before_transaction == df
735
735
736
736
737
+ @pytest .mark .skip ("This test is just for reference. Multiple upserts or delete+upsert doesn't work in a transaction" )
737
738
def test_transaction_multiple_upserts (catalog : Catalog ) -> None :
738
739
identifier = "default.test_multi_upsert"
739
740
_drop_table (catalog , identifier )
@@ -747,24 +748,28 @@ def test_transaction_multiple_upserts(catalog: Catalog) -> None:
747
748
tbl = catalog .create_table (identifier , schema = schema )
748
749
749
750
# Define exact schema: required int32 and required string
750
- arrow_schema = pa .schema ([
751
- pa .field ("id" , pa .int32 (), nullable = False ),
752
- pa .field ("name" , pa .string (), nullable = False ),
753
- ])
751
+ arrow_schema = pa .schema (
752
+ [
753
+ pa .field ("id" , pa .int32 (), nullable = False ),
754
+ pa .field ("name" , pa .string (), nullable = False ),
755
+ ]
756
+ )
754
757
755
758
tbl .append (pa .Table .from_pylist ([{"id" : 1 , "name" : "Alice" }], schema = arrow_schema ))
756
759
757
760
df = pa .Table .from_pylist ([{"id" : 2 , "name" : "Bob" }, {"id" : 1 , "name" : "Alicia" }], schema = arrow_schema )
758
761
759
762
with tbl .transaction () as txn :
763
+ txn .append (df )
764
+ txn .delete (delete_filter = "id = 1" )
765
+ txn .append (df )
760
766
# This should read the uncommitted changes?
761
767
txn .upsert (df , join_cols = ["id" ])
762
768
763
- txn .upsert (df , join_cols = ["id" ])
769
+ # txn.upsert(df, join_cols=["id"])
764
770
765
771
result = tbl .scan ().to_arrow ().to_pylist ()
766
772
assert sorted (result , key = lambda x : x ["id" ]) == [
767
773
{"id" : 1 , "name" : "Alicia" },
768
774
{"id" : 2 , "name" : "Bob" },
769
775
]
770
-
0 commit comments