@@ -325,7 +325,7 @@ def test_athena_to_iceberg_overwrite_partitions_merge_cols_error(
325
325
def test_athena_to_iceberg_schema_evolution_add_columns (
326
326
path : str , path2 : str , glue_database : str , glue_table : str
327
327
) -> None :
328
- df = pd .DataFrame ({"c0" : [0 , 1 , 2 ], "c1" : [3 , 4 , 5 ]})
328
+ df = pd .DataFrame ({"c0" : [0 , 1 , 2 ], "c1" : [6 , 7 , 8 ]})
329
329
wr .athena .to_iceberg (
330
330
df = df ,
331
331
database = glue_database ,
@@ -336,9 +336,9 @@ def test_athena_to_iceberg_schema_evolution_add_columns(
336
336
schema_evolution = True ,
337
337
)
338
338
339
- df [ "c2" ] = [ 6 , 7 , 8 ]
339
+ df2 = pd . DataFrame ({ "c0" : [ 3 , 4 , 5 ], "c2" : [ 9 , 10 , 11 ]})
340
340
wr .athena .to_iceberg (
341
- df = df ,
341
+ df = df2 ,
342
342
database = glue_database ,
343
343
table = glue_table ,
344
344
table_location = path ,
@@ -348,20 +348,25 @@ def test_athena_to_iceberg_schema_evolution_add_columns(
348
348
)
349
349
350
350
column_types = wr .catalog .get_table_types (glue_database , glue_table )
351
- assert len (column_types ) == len ( df . columns )
351
+ assert len (column_types ) == 3
352
352
353
353
df_out = wr .athena .read_sql_table (
354
354
table = glue_table ,
355
355
database = glue_database ,
356
356
ctas_approach = False ,
357
357
unload_approach = False ,
358
358
)
359
- assert len (df_out ) == len (df ) * 2
360
359
361
- df ["c3" ] = [9 , 10 , 11 ]
360
+ df_expected = pd .DataFrame (
361
+ {"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 ]},
362
+ dtype = "Int64" ,
363
+ )
364
+ assert_pandas_equals (df_out .sort_values (by = ["c0" ]).reset_index (drop = True ), df_expected )
365
+
366
+ df3 = pd .DataFrame ({"c0" : [12 ], "c1" : [13 ], "c2" : [14 ], "c3" : [15 ]})
362
367
with pytest .raises (wr .exceptions .InvalidArgumentValue ):
363
368
wr .athena .to_iceberg (
364
- df = df ,
369
+ df = df3 ,
365
370
database = glue_database ,
366
371
table = glue_table ,
367
372
table_location = path ,
0 commit comments