@@ -8891,6 +8891,62 @@ def test_load_table_from_dataframe_with_csv_source_format(self):
88918891 sent_config = load_table_from_file .mock_calls [0 ][2 ]["job_config" ]
88928892 assert sent_config .source_format == job .SourceFormat .CSV
88938893
8894+ @unittest .skipIf (
8895+ pandas is None or PANDAS_INSTALLED_VERSION < PANDAS_MINIUM_VERSION ,
8896+ "Only `pandas version >=1.0.0` supported" ,
8897+ )
8898+ @unittest .skipIf (pyarrow is None , "Requires `pyarrow`" )
8899+ def test_load_table_from_dataframe_w_higher_scale_decimal128_datatype (self ):
8900+ from google .cloud .bigquery .client import _DEFAULT_NUM_RETRIES
8901+ from google .cloud .bigquery import job
8902+ from google .cloud .bigquery .schema import SchemaField
8903+ from decimal import Decimal
8904+
8905+ client = self ._make_client ()
8906+ dataframe = pandas .DataFrame (
8907+ {
8908+ "x" : [
8909+ Decimal ("0.12345678901234560000000000000000000000" ),
8910+ Decimal ("01234567890123456789012345678901234567.1234567891" ),
8911+ ]
8912+ }
8913+ )
8914+ load_patch = mock .patch (
8915+ "google.cloud.bigquery.client.Client.load_table_from_file" , autospec = True
8916+ )
8917+
8918+ get_table_patch = mock .patch (
8919+ "google.cloud.bigquery.client.Client.get_table" ,
8920+ autospec = True ,
8921+ return_value = mock .Mock (schema = [SchemaField ("x" , "BIGNUMERIC" , "NULLABLE" )]),
8922+ )
8923+
8924+ with load_patch as load_table_from_file , get_table_patch :
8925+ client .load_table_from_dataframe (
8926+ dataframe , self .TABLE_REF , location = self .LOCATION
8927+ )
8928+
8929+ load_table_from_file .assert_called_once_with (
8930+ client ,
8931+ mock .ANY ,
8932+ self .TABLE_REF ,
8933+ num_retries = _DEFAULT_NUM_RETRIES ,
8934+ rewind = True ,
8935+ size = mock .ANY ,
8936+ job_id = mock .ANY ,
8937+ job_id_prefix = None ,
8938+ location = self .LOCATION ,
8939+ project = None ,
8940+ job_config = mock .ANY ,
8941+ timeout = DEFAULT_TIMEOUT ,
8942+ )
8943+
8944+ sent_config = load_table_from_file .mock_calls [0 ][2 ]["job_config" ]
8945+ assert sent_config .source_format == job .SourceFormat .PARQUET
8946+ assert tuple (sent_config .schema ) == (
8947+ SchemaField ("x" , "BIGNUMERIC" , "NULLABLE" , None ),
8948+ )
8949+
88948950 def test_load_table_from_json_basic_use (self ):
88958951 from google .cloud .bigquery .client import _DEFAULT_NUM_RETRIES
88968952 from google .cloud .bigquery import job
0 commit comments