2424import google .api_core .retry
2525import pkg_resources
2626import pytest
27- import pytz
2827
2928from google .cloud import bigquery
30- from google .cloud .bigquery ._pandas_helpers import _BIGNUMERIC_SUPPORT
3129from . import helpers
3230
3331
@@ -64,7 +62,7 @@ def test_load_table_from_dataframe_w_automatic_schema(bigquery_client, dataset_i
6462 datetime .datetime (2012 , 3 , 14 , 15 , 16 ),
6563 ],
6664 dtype = "datetime64[ns]" ,
67- ).dt .tz_localize (pytz .utc ),
65+ ).dt .tz_localize (datetime . timezone .utc ),
6866 ),
6967 (
7068 "dt_col" ,
@@ -189,12 +187,11 @@ def test_load_table_from_dataframe_w_nulls(bigquery_client, dataset_id):
189187 bigquery .SchemaField ("geo_col" , "GEOGRAPHY" ),
190188 bigquery .SchemaField ("int_col" , "INTEGER" ),
191189 bigquery .SchemaField ("num_col" , "NUMERIC" ),
190+ bigquery .SchemaField ("bignum_col" , "BIGNUMERIC" ),
192191 bigquery .SchemaField ("str_col" , "STRING" ),
193192 bigquery .SchemaField ("time_col" , "TIME" ),
194193 bigquery .SchemaField ("ts_col" , "TIMESTAMP" ),
195194 )
196- if _BIGNUMERIC_SUPPORT :
197- scalars_schema += (bigquery .SchemaField ("bignum_col" , "BIGNUMERIC" ),)
198195
199196 table_schema = scalars_schema + (
200197 # TODO: Array columns can't be read due to NULLABLE versus REPEATED
@@ -216,12 +213,11 @@ def test_load_table_from_dataframe_w_nulls(bigquery_client, dataset_id):
216213 ("geo_col" , nulls ),
217214 ("int_col" , nulls ),
218215 ("num_col" , nulls ),
216+ ("bignum_col" , nulls ),
219217 ("str_col" , nulls ),
220218 ("time_col" , nulls ),
221219 ("ts_col" , nulls ),
222220 ]
223- if _BIGNUMERIC_SUPPORT :
224- df_data .append (("bignum_col" , nulls ))
225221 df_data = collections .OrderedDict (df_data )
226222 dataframe = pandas .DataFrame (df_data , columns = df_data .keys ())
227223
@@ -297,12 +293,11 @@ def test_load_table_from_dataframe_w_explicit_schema(bigquery_client, dataset_id
297293 bigquery .SchemaField ("geo_col" , "GEOGRAPHY" ),
298294 bigquery .SchemaField ("int_col" , "INTEGER" ),
299295 bigquery .SchemaField ("num_col" , "NUMERIC" ),
296+ bigquery .SchemaField ("bignum_col" , "BIGNUMERIC" ),
300297 bigquery .SchemaField ("str_col" , "STRING" ),
301298 bigquery .SchemaField ("time_col" , "TIME" ),
302299 bigquery .SchemaField ("ts_col" , "TIMESTAMP" ),
303300 )
304- if _BIGNUMERIC_SUPPORT :
305- scalars_schema += (bigquery .SchemaField ("bignum_col" , "BIGNUMERIC" ),)
306301
307302 table_schema = scalars_schema + (
308303 # TODO: Array columns can't be read due to NULLABLE versus REPEATED
@@ -340,6 +335,14 @@ def test_load_table_from_dataframe_w_explicit_schema(bigquery_client, dataset_id
340335 decimal .Decimal ("99999999999999999999999999999.999999999" ),
341336 ],
342337 ),
338+ (
339+ "bignum_col" ,
340+ [
341+ decimal .Decimal ("-{d38}.{d38}" .format (d38 = "9" * 38 )),
342+ None ,
343+ decimal .Decimal ("{d38}.{d38}" .format (d38 = "9" * 38 )),
344+ ],
345+ ),
343346 ("str_col" , ["abc" , None , "def" ]),
344347 (
345348 "time_col" ,
@@ -348,23 +351,14 @@ def test_load_table_from_dataframe_w_explicit_schema(bigquery_client, dataset_id
348351 (
349352 "ts_col" ,
350353 [
351- datetime .datetime (1 , 1 , 1 , 0 , 0 , 0 , tzinfo = pytz .utc ),
354+ datetime .datetime (1 , 1 , 1 , 0 , 0 , 0 , tzinfo = datetime . timezone .utc ),
352355 None ,
353- datetime .datetime (9999 , 12 , 31 , 23 , 59 , 59 , 999999 , tzinfo = pytz .utc ),
356+ datetime .datetime (
357+ 9999 , 12 , 31 , 23 , 59 , 59 , 999999 , tzinfo = datetime .timezone .utc
358+ ),
354359 ],
355360 ),
356361 ]
357- if _BIGNUMERIC_SUPPORT :
358- df_data .append (
359- (
360- "bignum_col" ,
361- [
362- decimal .Decimal ("-{d38}.{d38}" .format (d38 = "9" * 38 )),
363- None ,
364- decimal .Decimal ("{d38}.{d38}" .format (d38 = "9" * 38 )),
365- ],
366- )
367- )
368362 df_data = collections .OrderedDict (df_data )
369363 dataframe = pandas .DataFrame (df_data , dtype = "object" , columns = df_data .keys ())
370364
@@ -484,10 +478,10 @@ def test_load_table_from_dataframe_w_explicit_schema_source_format_csv(
484478 (
485479 "ts_col" ,
486480 [
487- datetime .datetime (1 , 1 , 1 , 0 , 0 , 0 , tzinfo = pytz .utc ),
481+ datetime .datetime (1 , 1 , 1 , 0 , 0 , 0 , tzinfo = datetime . timezone .utc ),
488482 None ,
489483 datetime .datetime (
490- 9999 , 12 , 31 , 23 , 59 , 59 , 999999 , tzinfo = pytz .utc
484+ 9999 , 12 , 31 , 23 , 59 , 59 , 999999 , tzinfo = datetime . timezone .utc
491485 ),
492486 ],
493487 ),
0 commit comments