Skip to content

Commit 5f561c5

Browse files
committed
Expand athena iceberg add columns test to check values
1 parent bdb81a7 commit 5f561c5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tests/unit/test_athena_iceberg.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,10 @@ def test_athena_to_iceberg_overwrite_partitions_merge_cols_error(
321321
mode="overwrite_partitions",
322322
)
323323

324-
325324
def test_athena_to_iceberg_schema_evolution_add_columns(
326325
path: str, path2: str, glue_database: str, glue_table: str
327326
) -> None:
328-
df = pd.DataFrame({"c0": [0, 1, 2], "c1": [3, 4, 5]})
327+
df = pd.DataFrame({"c0": [0, 1, 2], "c1": [6, 7, 8]})
329328
wr.athena.to_iceberg(
330329
df=df,
331330
database=glue_database,
@@ -336,9 +335,9 @@ def test_athena_to_iceberg_schema_evolution_add_columns(
336335
schema_evolution=True,
337336
)
338337

339-
df["c2"] = [6, 7, 8]
338+
df2 = pd.DataFrame({"c0": [3, 4, 5], "c2": [9, 10, 11]})
340339
wr.athena.to_iceberg(
341-
df=df,
340+
df=df2,
342341
database=glue_database,
343342
table=glue_table,
344343
table_location=path,
@@ -348,20 +347,25 @@ def test_athena_to_iceberg_schema_evolution_add_columns(
348347
)
349348

350349
column_types = wr.catalog.get_table_types(glue_database, glue_table)
351-
assert len(column_types) == len(df.columns)
350+
assert len(column_types) == 3
352351

353352
df_out = wr.athena.read_sql_table(
354353
table=glue_table,
355354
database=glue_database,
356355
ctas_approach=False,
357356
unload_approach=False,
358357
)
359-
assert len(df_out) == len(df) * 2
360358

361-
df["c3"] = [9, 10, 11]
359+
df_expected = pd.DataFrame(
360+
{"c0": [0, 1, 2, 3, 4, 5], "c1": [6, 7, 8, np.nan, np.nan, np.nan], "c2": [np.nan, np.nan, np.nan, 9, 10, 11]},
361+
dtype="Int64",
362+
)
363+
assert_pandas_equals(df_out.sort_values(by=["c0"]).reset_index(drop=True), df_expected)
364+
365+
df3 = pd.DataFrame({"c0": [12], "c1": [13], "c2": [14], "c3": [15]})
362366
with pytest.raises(wr.exceptions.InvalidArgumentValue):
363367
wr.athena.to_iceberg(
364-
df=df,
368+
df=df3,
365369
database=glue_database,
366370
table=glue_table,
367371
table_location=path,

0 commit comments

Comments
 (0)