Skip to content

Commit 2774bd3

Browse files
committed
fix: address linting and mypy type errors in maintenance tests
1 parent 5c8dc67 commit 2774bd3

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

tests/table/test_maintenance.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,27 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
import random
18+
1819
import pyarrow as pa
19-
import pytest
2020

2121
from pyiceberg.catalog import Catalog
22+
from pyiceberg.exceptions import NoSuchNamespaceError
23+
from pyiceberg.partitioning import PartitionField, PartitionSpec
2224
from pyiceberg.schema import Schema
23-
from pyiceberg.partitioning import PartitionSpec, PartitionField
2425
from pyiceberg.transforms import IdentityTransform
25-
from pyiceberg.exceptions import NoSuchNamespaceError
2626

2727

2828
def test_maintenance_compact(catalog: Catalog) -> None:
2929
# Setup Schema and specs
30-
from pyiceberg.types import NestedField, StringType, LongType
30+
from pyiceberg.types import LongType, NestedField, StringType
31+
3132
schema = Schema(
3233
NestedField(1, "id", LongType()),
3334
NestedField(2, "category", StringType()),
3435
NestedField(3, "value", LongType()),
3536
)
36-
spec = PartitionSpec(
37-
PartitionField(source_id=2, field_id=1000, transform=IdentityTransform(), name="category")
38-
)
39-
37+
spec = PartitionSpec(PartitionField(source_id=2, field_id=1000, transform=IdentityTransform(), name="category"))
38+
4039
# Create the namespace and table
4140
try:
4241
catalog.create_namespace("default")
@@ -51,11 +50,15 @@ def test_maintenance_compact(catalog: Catalog) -> None:
5150
# Append many small data files
5251
categories = ["cat1", "cat2", "cat3"]
5352
for i in range(12):
54-
table.append(pa.table({
55-
"id": list(range(i * 10, (i + 1) * 10)),
56-
"category": [categories[i % 3]] * 10,
57-
"value": [random.randint(1, 100) for _ in range(10)],
58-
}))
53+
table.append(
54+
pa.table(
55+
{
56+
"id": list(range(i * 10, (i + 1) * 10)),
57+
"category": [categories[i % 3]] * 10,
58+
"value": [random.randint(1, 100) for _ in range(10)],
59+
}
60+
)
61+
)
5962

6063
# Verify state before compaction
6164
before_files = list(table.scan().plan_files())
@@ -74,28 +77,30 @@ def test_maintenance_compact(catalog: Catalog) -> None:
7477
# Ensure snapshot properties specify the replace-operation
7578
new_snapshot = table.current_snapshot()
7679
assert new_snapshot is not None
80+
assert new_snapshot.summary is not None
7781
assert new_snapshot.summary.get("snapshot-type") == "replace"
7882
assert new_snapshot.summary.get("replace-operation") == "compaction"
7983

8084

8185
def test_maintenance_compact_empty_table(catalog: Catalog) -> None:
82-
from pyiceberg.types import NestedField, StringType, LongType
86+
from pyiceberg.types import LongType, NestedField, StringType
87+
8388
schema = Schema(
8489
NestedField(1, "id", LongType()),
8590
NestedField(2, "category", StringType()),
8691
)
87-
92+
8893
try:
8994
catalog.create_namespace("default")
9095
except NoSuchNamespaceError:
9196
pass
92-
97+
9398
table = catalog.create_table("default.test_compaction_empty", schema=schema)
9499
before_snapshots = len(table.history())
95-
100+
96101
# Should safely return doing nothing
97102
table.maintenance.compact()
98-
103+
99104
table.refresh()
100105
after_snapshots = len(table.history())
101106
assert before_snapshots == after_snapshots # No new snapshot should be made

0 commit comments

Comments
 (0)