Skip to content

Commit 8f425fb

Browse files
committed
test: add test for reverting back to unsorted sort order
1 parent 18ced3f commit 8f425fb

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/integration/test_sort_order_update.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,29 @@ def test_update_existing_sort_order(catalog: Catalog, format_version: str, table
138138
SortField(source_id=1, transform=IdentityTransform(), direction=SortDirection.ASC, null_order=NullOrder.NULLS_FIRST),
139139
order_id=1,
140140
)
141+
142+
143+
@pytest.mark.integration
144+
@pytest.mark.parametrize(
145+
"catalog, format_version",
146+
[
147+
(pytest.lazy_fixture("session_catalog"), "1"),
148+
(pytest.lazy_fixture("session_catalog_hive"), "1"),
149+
(pytest.lazy_fixture("session_catalog"), "2"),
150+
(pytest.lazy_fixture("session_catalog_hive"), "2"),
151+
],
152+
)
153+
def test_update_existing_sort_order_with_unsorted_sort_order(catalog: Catalog, format_version: str, table_schema_simple: Schema) -> None:
154+
simple_table = _simple_table(catalog, table_schema_simple, format_version)
155+
simple_table.update_sort_order().asc("foo", IdentityTransform(), NullOrder.NULLS_FIRST).commit()
156+
assert simple_table.sort_order() == SortOrder(
157+
SortField(source_id=1, transform=IdentityTransform(), direction=SortDirection.ASC, null_order=NullOrder.NULLS_FIRST),
158+
order_id=1,
159+
)
160+
# Table should now be unsorted
161+
simple_table.update_sort_order().commit()
162+
# Go back to the first sort order
163+
assert (
164+
len(simple_table.sort_orders()) == 2
165+
)
166+
assert simple_table.sort_order() == SortOrder(order_id=0)

0 commit comments

Comments
 (0)