@@ -1389,6 +1389,31 @@ def test_upload_data_with_missing_schema_fields_raises_error(self):
1389
1389
private_key = self .credentials ,
1390
1390
table_schema = test_schema )
1391
1391
1392
+ def test_upload_data_with_timestamp (self ):
1393
+ df = tm .makeMixedDataFrame ()
1394
+ test_id = "21"
1395
+ test_size = 6
1396
+ df = DataFrame (np .random .randn (test_size , 4 ), index = range (test_size ),
1397
+ columns = list ('ABCD' ))
1398
+ test_timestamp = datetime .now (pytz .timezone ('UTC' ))
1399
+ df ['times' ] = test_timestamp
1400
+
1401
+ gbq .to_gbq (
1402
+ df , self .destination_table + test_id ,
1403
+ _get_project_id (),
1404
+ private_key = self .credentials )
1405
+
1406
+ result_df = gbq .read_gbq ("SELECT * FROM {0}" .format (
1407
+ self .destination_table + test_id ),
1408
+ project_id = _get_project_id (),
1409
+ private_key = self .credentials )
1410
+
1411
+ assert len (result_df ) == test_size
1412
+
1413
+ expected = df ['times' ].astype ('M8[ns]' ).sort_values ()
1414
+ result = result_df ['times' ].astype ('M8[ns]' ).sort_values ()
1415
+ tm .assert_numpy_array_equal (expected .values , result .values )
1416
+
1392
1417
def test_list_dataset (self ):
1393
1418
dataset_id = self .dataset_prefix + "1"
1394
1419
assert dataset_id in self .dataset .datasets ()
0 commit comments