11import itertools
22import logging
33import math
4- from datetime import datetime
4+ from datetime import datetime , timedelta , timezone
55
66import boto3
77import numpy as np
@@ -362,7 +362,7 @@ def test_timezone_file(path, use_threads):
362362 assert df .equals (df2 )
363363
364364
365- @pytest .mark .parametrize ("use_threads" , [False ])
365+ @pytest .mark .parametrize ("use_threads" , [True , False ])
366366def test_timezone_file_columns (path , use_threads ):
367367 file_path = f"{ path } 0.parquet"
368368 df = pd .DataFrame ({"c0" : [datetime .utcnow (), datetime .utcnow ()], "c1" : [1.1 , 2.2 ]})
@@ -371,3 +371,19 @@ def test_timezone_file_columns(path, use_threads):
371371 wr .s3 .wait_objects_exist (paths = [file_path ], use_threads = use_threads )
372372 df2 = wr .s3 .read_parquet (path , columns = ["c1" ], use_threads = use_threads )
373373 assert df [["c1" ]].equals (df2 )
374+
375+
376+ @pytest .mark .parametrize ("use_threads" , [True , False ])
377+ def test_timezone_raw_values (path , use_threads ):
378+ df = pd .DataFrame ({"c0" : [1.1 , 2.2 ], "par" : ["a" , "b" ]})
379+ df ["c1" ] = pd .to_datetime (datetime .now (timezone .utc ))
380+ df ["c2" ] = pd .to_datetime (datetime (2011 , 11 , 4 , 0 , 5 , 23 , tzinfo = timezone (timedelta (seconds = 14400 ))))
381+ df ["c3" ] = pd .to_datetime (datetime (2011 , 11 , 4 , 0 , 5 , 23 , tzinfo = timezone (- timedelta (seconds = 14400 ))))
382+ df ["c4" ] = pd .to_datetime (datetime (2011 , 11 , 4 , 0 , 5 , 23 , tzinfo = timezone (timedelta (hours = - 8 ))))
383+ paths = wr .s3 .to_parquet (partition_cols = ["par" ], df = df , path = path , dataset = True , sanitize_columns = False )["paths" ]
384+ wr .s3 .wait_objects_exist (paths , use_threads = use_threads )
385+ df2 = wr .s3 .read_parquet (path , dataset = True , use_threads = use_threads )
386+ df3 = pd .concat ([pd .read_parquet (p ) for p in paths ], ignore_index = True )
387+ df2 ["par" ] = df2 ["par" ].astype ("string" )
388+ df3 ["par" ] = df3 ["par" ].astype ("string" )
389+ assert df2 .equals (df3 )
0 commit comments