@@ -310,13 +310,15 @@ def test_should_properly_handle_timestamp_unix_epoch(self, project_id):
310310 credentials = self .credentials ,
311311 dialect = "legacy" ,
312312 )
313- tm .assert_frame_equal (
314- df ,
315- DataFrame (
316- {"unix_epoch" : ["1970-01-01T00:00:00.000000Z" ]},
317- dtype = "datetime64[ns]" ,
318- ),
313+ expected = DataFrame (
314+ {"unix_epoch" : ["1970-01-01T00:00:00.000000Z" ]},
315+ dtype = "datetime64[ns]" ,
319316 )
317+ if expected ["unix_epoch" ].dt .tz is None :
318+ expected ["unix_epoch" ] = expected ["unix_epoch" ].dt .tz_localize (
319+ "UTC"
320+ )
321+ tm .assert_frame_equal (df , expected )
320322
321323 def test_should_properly_handle_arbitrary_timestamp (self , project_id ):
322324 query = 'SELECT TIMESTAMP("2004-09-15 05:00:00") AS valid_timestamp'
@@ -326,13 +328,15 @@ def test_should_properly_handle_arbitrary_timestamp(self, project_id):
326328 credentials = self .credentials ,
327329 dialect = "legacy" ,
328330 )
329- tm .assert_frame_equal (
330- df ,
331- DataFrame (
332- {"valid_timestamp" : ["2004-09-15T05:00:00.000000Z" ]},
333- dtype = "datetime64[ns]" ,
334- ),
331+ expected = DataFrame (
332+ {"valid_timestamp" : ["2004-09-15T05:00:00.000000Z" ]},
333+ dtype = "datetime64[ns]" ,
335334 )
335+ if expected ["valid_timestamp" ].dt .tz is None :
336+ expected ["valid_timestamp" ] = expected [
337+ "valid_timestamp"
338+ ].dt .tz_localize ("UTC" )
339+ tm .assert_frame_equal (df , expected )
336340
337341 def test_should_properly_handle_datetime_unix_epoch (self , project_id ):
338342 query = 'SELECT DATETIME("1970-01-01 00:00:00") AS unix_epoch'
@@ -368,7 +372,7 @@ def test_should_properly_handle_arbitrary_datetime(self, project_id):
368372 "expression, is_expected_dtype" ,
369373 [
370374 ("current_date()" , pandas .api .types .is_datetime64_ns_dtype ),
371- ("current_timestamp()" , pandas .api .types .is_datetime64_ns_dtype ),
375+ ("current_timestamp()" , pandas .api .types .is_datetime64tz_dtype ),
372376 ("current_datetime()" , pandas .api .types .is_datetime64_ns_dtype ),
373377 ("TRUE" , pandas .api .types .is_bool_dtype ),
374378 ("FALSE" , pandas .api .types .is_bool_dtype ),
@@ -402,9 +406,11 @@ def test_should_properly_handle_null_timestamp(self, project_id):
402406 credentials = self .credentials ,
403407 dialect = "legacy" ,
404408 )
405- tm .assert_frame_equal (
406- df , DataFrame ({"null_timestamp" : [NaT ]}, dtype = "datetime64[ns]" )
409+ expected = DataFrame ({"null_timestamp" : [NaT ]}, dtype = "datetime64[ns]" )
410+ expected ["null_timestamp" ] = expected ["null_timestamp" ].dt .tz_localize (
411+ "UTC"
407412 )
413+ tm .assert_frame_equal (df , expected )
408414
409415 def test_should_properly_handle_null_datetime (self , project_id ):
410416 query = "SELECT CAST(NULL AS DATETIME) AS null_datetime"
@@ -594,6 +600,7 @@ def test_zero_rows(self, project_id):
594600 expected_result = DataFrame (
595601 empty_columns , columns = ["title" , "id" , "is_bot" , "ts" ]
596602 )
603+ expected_result ["ts" ] = expected_result ["ts" ].dt .tz_localize ("UTC" )
597604 tm .assert_frame_equal (df , expected_result , check_index_type = False )
598605
599606 def test_one_row_one_column (self , project_id ):
0 commit comments