Skip to content

Commit b11c083

Browse files
committed
linting
Signed-off-by: HaoXuAI <sduxuhao@gmail.com>
1 parent 05e3a65 commit b11c083

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

sdk/python/tests/unit/test_table_format.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def test_iceberg_table_format_creation(self):
2121
iceberg_format = IcebergFormat(
2222
catalog="my_catalog",
2323
namespace="my_namespace",
24-
catalog_properties={"catalog.uri": "s3://bucket/warehouse"},
25-
table_properties={"format-version": "2"},
24+
properties={"catalog.uri": "s3://bucket/warehouse", "format-version": "2"},
2625
)
2726

2827
assert iceberg_format.format_type == TableFormatType.ICEBERG
@@ -45,8 +44,8 @@ def test_iceberg_table_format_minimal(self):
4544
def test_delta_table_format_creation(self):
4645
"""Test DeltaFormat creation and properties."""
4746
delta_format = DeltaFormat(
48-
table_properties={"delta.autoOptimize.optimizeWrite": "true"},
4947
checkpoint_location="s3://bucket/checkpoints",
48+
properties={"delta.autoOptimize.optimizeWrite": "true"},
5049
)
5150

5251
assert delta_format.format_type == TableFormatType.DELTA
@@ -63,7 +62,7 @@ def test_hudi_table_format_creation(self):
6362
table_type="COPY_ON_WRITE",
6463
record_key="id",
6564
precombine_field="timestamp",
66-
table_properties={
65+
properties={
6766
"hoodie.compaction.strategy": "org.apache.hudi.table.action.compact.strategy.LogFileSizeBasedCompactionStrategy"
6867
},
6968
)
@@ -102,8 +101,7 @@ def test_table_format_serialization(self):
102101
iceberg_format = IcebergFormat(
103102
catalog="test_catalog",
104103
namespace="test_namespace",
105-
catalog_properties={"key1": "value1"},
106-
table_properties={"key2": "value2"},
104+
properties={"key1": "value1", "key2": "value2"},
107105
)
108106

109107
iceberg_dict = iceberg_format.to_dict()
@@ -112,20 +110,19 @@ def test_table_format_serialization(self):
112110
assert iceberg_restored.format_type == iceberg_format.format_type
113111
assert iceberg_restored.catalog == iceberg_format.catalog
114112
assert iceberg_restored.namespace == iceberg_format.namespace
115-
assert iceberg_restored.catalog_properties == iceberg_format.catalog_properties
116-
assert iceberg_restored.table_properties == iceberg_format.table_properties
113+
assert iceberg_restored.properties == iceberg_format.properties
117114

118115
# Test Delta
119116
delta_format = DeltaFormat(
120-
table_properties={"key": "value"},
121117
checkpoint_location="s3://bucket/checkpoints",
118+
properties={"key": "value"},
122119
)
123120

124121
delta_dict = delta_format.to_dict()
125122
delta_restored = DeltaFormat.from_dict(delta_dict)
126123

127124
assert delta_restored.format_type == delta_format.format_type
128-
assert delta_restored.table_properties == delta_format.table_properties
125+
assert delta_restored.properties == delta_format.properties
129126
assert delta_restored.checkpoint_location == delta_format.checkpoint_location
130127

131128
# Test Hudi
@@ -182,8 +179,7 @@ def test_table_format_from_dict(self):
182179
"format_type": "iceberg",
183180
"catalog": "test_catalog",
184181
"namespace": "test_namespace",
185-
"catalog_properties": {"key1": "value1"},
186-
"table_properties": {"key2": "value2"},
182+
"properties": {"key1": "value1", "key2": "value2"},
187183
}
188184
iceberg_format = table_format_from_dict(iceberg_dict)
189185
assert isinstance(iceberg_format, IcebergFormat)
@@ -192,7 +188,7 @@ def test_table_format_from_dict(self):
192188
# Test Delta
193189
delta_dict = {
194190
"format_type": "delta",
195-
"table_properties": {"key": "value"},
191+
"properties": {"key": "value"},
196192
"checkpoint_location": "s3://bucket/checkpoints",
197193
}
198194
delta_format = table_format_from_dict(delta_dict)
@@ -205,7 +201,7 @@ def test_table_format_from_dict(self):
205201
"table_type": "MERGE_ON_READ",
206202
"record_key": "id",
207203
"precombine_field": "ts",
208-
"table_properties": {},
204+
"properties": {},
209205
}
210206
hudi_format = table_format_from_dict(hudi_dict)
211207
assert isinstance(hudi_format, HudiFormat)
@@ -221,8 +217,7 @@ def test_table_format_from_json(self):
221217
"format_type": "iceberg",
222218
"catalog": "test_catalog",
223219
"namespace": "test_namespace",
224-
"catalog_properties": {},
225-
"table_properties": {},
220+
"properties": {},
226221
}
227222
json_str = json.dumps(iceberg_dict)
228223
iceberg_format = table_format_from_json(json_str)
@@ -264,15 +259,15 @@ def test_table_format_property_edge_cases(self):
264259
assert iceberg_format.get_property("snapshot-id") == "456"
265260

266261
# Test empty properties
267-
delta_format = DeltaFormat(table_properties=None)
268-
assert len(delta_format.table_properties) == 0
262+
delta_format = DeltaFormat(properties=None)
263+
assert len(delta_format.properties) == 0
269264

270265
# Test None values in constructors
271266
hudi_format = HudiFormat(
272267
table_type=None,
273268
record_key=None,
274269
precombine_field=None,
275-
table_properties=None,
270+
properties=None,
276271
)
277272
assert hudi_format.table_type is None
278273
assert hudi_format.record_key is None
@@ -285,7 +280,7 @@ def test_hudi_format_comprehensive(self):
285280
table_type="COPY_ON_WRITE",
286281
record_key="id,uuid",
287282
precombine_field="ts",
288-
table_properties={"custom.prop": "value"},
283+
properties={"custom.prop": "value"},
289284
)
290285

291286
assert (
@@ -314,7 +309,7 @@ def test_table_format_with_special_characters(self):
314309
iceberg_format = IcebergFormat(
315310
catalog="测试目录", # Chinese
316311
namespace="тест_ns", # Cyrillic
317-
catalog_properties={"special.key": "value with spaces & symbols!@#$%^&*()"},
312+
properties={"special.key": "value with spaces & symbols!@#$%^&*()"},
318313
)
319314

320315
# Serialization roundtrip should preserve special characters
@@ -323,6 +318,6 @@ def test_table_format_with_special_characters(self):
323318
assert restored.catalog == "测试目录"
324319
assert restored.namespace == "тест_ns"
325320
assert (
326-
restored.catalog_properties["special.key"]
321+
restored.properties["special.key"]
327322
== "value with spaces & symbols!@#$%^&*()"
328323
)

0 commit comments

Comments
 (0)