Skip to content

Commit 751d44e

Browse files
committed
Adjust partition comparison for partition evolution
1 parent 57a0ed6 commit 751d44e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/integration/test_inspect_table.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import math
2020
from datetime import date, datetime
21+
from typing import Any
2122

2223
import pyarrow as pa
2324
import pytest
@@ -208,9 +209,18 @@ def _inspect_files_asserts(df: pa.Table, spark_df: DataFrame) -> None:
208209
def _check_pyiceberg_df_equals_spark_df(df: pa.Table, spark_df: DataFrame) -> None:
209210
lhs = df.to_pandas().sort_values("last_updated_at")
210211
rhs = spark_df.toPandas().sort_values("last_updated_at")
212+
213+
def _normalize_partition(d: dict[str, Any]) -> dict[str, Any]:
214+
return {k: v for k, v in d.items() if v is not None}
215+
211216
for column in df.column_names:
212217
for left, right in zip(lhs[column].to_list(), rhs[column].to_list(), strict=True):
213-
assert left == right, f"Difference in column {column}: {left} != {right}"
218+
if column == "partition":
219+
assert _normalize_partition(left) == _normalize_partition(right), (
220+
f"Difference in column {column}: {left} != {right}"
221+
)
222+
else:
223+
assert left == right, f"Difference in column {column}: {left} != {right}"
214224

215225

216226
@pytest.mark.integration

0 commit comments

Comments
 (0)