@@ -1573,6 +1573,32 @@ class Outer(qv.Table):
15731573 assert o2 .inner .name == "b"
15741574
15751575
1576+ def test_cached_accessor_not_stale_after_set_column ():
1577+ # Access a column to exercise accessor caching, then mutate via set_column
1578+ t = Pair .from_kwargs (x = [1 , 2 , 3 ], y = [4 , 5 , 6 ])
1579+ _ = t .x # populate cache on this instance
1580+
1581+ t2 = t .set_column ("x" , [7 , 8 , 9 ])
1582+
1583+ # Original remains unchanged
1584+ assert t .x .equals (pa .array ([1 , 2 , 3 ], pa .int64 ()))
1585+ # New table reflects mutation
1586+ assert t2 .x .equals (pa .array ([7 , 8 , 9 ], pa .int64 ()))
1587+
1588+
1589+ def test_cached_subtable_not_stale_after_set_column ():
1590+ # Access a subtable to exercise subtable caching, then mutate nested column
1591+ w = Wrapper .from_kwargs (id = ["a" , "b" , "c" ], pair = Pair .from_kwargs (x = [1 , 2 , 3 ], y = [4 , 5 , 6 ]))
1592+ _ = w .pair # populate subtable cache on this instance
1593+
1594+ w2 = w .set_column ("pair.x" , [7 , 8 , 9 ])
1595+
1596+ # Original remains unchanged
1597+ assert w .pair .x .equals (pa .array ([1 , 2 , 3 ], pa .int64 ()))
1598+ # New table reflects mutation
1599+ assert w2 .pair .x .equals (pa .array ([7 , 8 , 9 ], pa .int64 ()))
1600+
1601+
15761602def test_get_unique_indices_first ():
15771603 t = Pair .from_kwargs (x = [1 , 2 , 3 , 1 , 2 , 3 ], y = [4 , 5 , 6 , 4 , 5 , 6 ])
15781604
0 commit comments