@@ -1370,8 +1370,8 @@ def test_copy_replacing_filename(bucket):
13701370
13711371
13721372def test_unsigned_parquet (bucket , database , external_schema ):
1373- path = f"s3://{ bucket } /test_unsigned_parquet/"
13741373 table = "test_unsigned_parquet"
1374+ path = f"s3://{ bucket } /{ table } /"
13751375 wr .s3 .delete_objects (path = path )
13761376 df = pd .DataFrame ({"c0" : [0 , 0 , (2 ** 8 ) - 1 ], "c1" : [0 , 0 , (2 ** 16 ) - 1 ], "c2" : [0 , 0 , (2 ** 32 ) - 1 ]})
13771377 df ["c0" ] = df .c0 .astype ("uint8" )
@@ -1436,3 +1436,43 @@ def test_parquet_uint64(bucket):
14361436 assert df .c3 .max () == (2 ** 64 ) - 1
14371437 assert df .c4 .astype ("uint8" ).sum () == 3
14381438 wr .s3 .delete_objects (path = path )
1439+
1440+
1441+ def test_parquet_overwrite_partition_cols (bucket , database , external_schema ):
1442+ table = "test_parquet_overwrite_partition_cols"
1443+ path = f"s3://{ bucket } /{ table } /"
1444+ wr .s3 .delete_objects (path = path )
1445+ df = pd .DataFrame ({"c0" : [1 , 2 , 1 , 2 ], "c1" : [1 , 2 , 1 , 2 ], "c2" : [2 , 1 , 2 , 1 ]})
1446+
1447+ paths = wr .s3 .to_parquet (
1448+ df = df , path = path , dataset = True , database = database , table = table , mode = "overwrite" , partition_cols = ["c2" ]
1449+ )["paths" ]
1450+ wr .s3 .wait_objects_exist (paths = paths , use_threads = False )
1451+ df = wr .athena .read_sql_table (table = table , database = database )
1452+ assert len (df .index ) == 4
1453+ assert len (df .columns ) == 3
1454+ assert df .c0 .sum () == 6
1455+ assert df .c1 .sum () == 6
1456+ assert df .c2 .sum () == 6
1457+
1458+ paths = wr .s3 .to_parquet (
1459+ df = df , path = path , dataset = True , database = database , table = table , mode = "overwrite" , partition_cols = ["c1" , "c2" ]
1460+ )["paths" ]
1461+ wr .s3 .wait_objects_exist (paths = paths , use_threads = False )
1462+ df = wr .athena .read_sql_table (table = table , database = database )
1463+ assert len (df .index ) == 4
1464+ assert len (df .columns ) == 3
1465+ assert df .c0 .sum () == 6
1466+ assert df .c1 .sum () == 6
1467+ assert df .c2 .sum () == 6
1468+
1469+ engine = wr .catalog .get_engine ("aws-data-wrangler-redshift" )
1470+ df = wr .db .read_sql_table (con = engine , table = table , schema = external_schema )
1471+ assert len (df .index ) == 4
1472+ assert len (df .columns ) == 3
1473+ assert df .c0 .sum () == 6
1474+ assert df .c1 .sum () == 6
1475+ assert df .c2 .sum () == 6
1476+
1477+ wr .s3 .delete_objects (path = path )
1478+ wr .catalog .delete_table_if_exists (database = database , table = table )
0 commit comments