rambleraptor commented on code in PR #4209:
URL: https://github.com/apache/iceberg-python/pull/4209#discussion_r4429591457
##########
tests/catalog/test_catalog_behaviors.py:
##########
@@ -622,6 +622,79 @@ def test_concurrent_commit_table(catalog: Catalog,
table_schema_nested: Schema,
update.add_column(path="c", field_type=IntegerType())
+def test_stale_update_sort_order_reuses_equal_sort_order(
Review Comment:
Try running this test. I had AI whip up something to show an issue around
reassigned IDs + wrong orders becoming the default:
```
def test_stale_transaction_keeps_reassigned_sort_order_as_default(
catalog: Catalog, table_schema_nested: Schema, test_table_identifier:
Identifier
) -> None:
namespace = Catalog.namespace_from(test_table_identifier)
catalog.create_namespace(namespace)
table_a = catalog.create_table(test_table_identifier,
table_schema_nested)
table_b = catalog.load_table(test_table_identifier)
with table_a.update_sort_order() as update:
update.asc("foo", IdentityTransform())
with table_a.update_sort_order():
pass # Reset to unsorted
# Stale handle stages bar (id 1), baz (id 2), then bar again, which it
sends as an explicit SetDefault(1)
with table_b.transaction() as transaction:
with transaction.update_sort_order() as update:
update.asc("bar", IdentityTransform())
with transaction.update_sort_order() as update:
update.asc("baz", IdentityTransform())
with transaction.update_sort_order() as update:
update.asc("bar", IdentityTransform())
# bar and baz are reassigned to 2 and 3, so the default must follow bar
rather than foo's id 1
metadata = catalog.load_table(test_table_identifier).metadata
assert [sort_order.order_id for sort_order in metadata.sort_orders] ==
[0, 1, 2, 3]
assert metadata.default_sort_order_id == 2
assert metadata.sort_order().fields[0].source_id == 2
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]