@@ -8891,6 +8891,49 @@ def test_load_table_from_dataframe_with_csv_source_format(self):
8891
8891
sent_config = load_table_from_file .mock_calls [0 ][2 ]["job_config" ]
8892
8892
assert sent_config .source_format == job .SourceFormat .CSV
8893
8893
8894
+ @unittest .skipIf (pandas is None , "Requires `pandas`" )
8895
+ @unittest .skipIf (pyarrow is None , "Requires `pyarrow`" )
8896
+ def test_load_table_from_dataframe_w_higher_scale_decimal128_datatype (self ):
8897
+ from google .cloud .bigquery .client import _DEFAULT_NUM_RETRIES
8898
+ from google .cloud .bigquery import job
8899
+ from google .cloud .bigquery .schema import SchemaField
8900
+ from decimal import Decimal
8901
+
8902
+ client = self ._make_client ()
8903
+ dataframe = pandas .DataFrame ({"x" : [Decimal ("0.1234567891" )]})
8904
+ load_patch = mock .patch (
8905
+ "google.cloud.bigquery.client.Client.load_table_from_file" , autospec = True
8906
+ )
8907
+
8908
+ get_table_patch = mock .patch (
8909
+ "google.cloud.bigquery.client.Client.get_table" , autospec = True
8910
+ )
8911
+ with load_patch as load_table_from_file , get_table_patch :
8912
+ client .load_table_from_dataframe (
8913
+ dataframe , self .TABLE_REF , location = self .LOCATION
8914
+ )
8915
+
8916
+ load_table_from_file .assert_called_once_with (
8917
+ client ,
8918
+ mock .ANY ,
8919
+ self .TABLE_REF ,
8920
+ num_retries = _DEFAULT_NUM_RETRIES ,
8921
+ rewind = True ,
8922
+ size = mock .ANY ,
8923
+ job_id = mock .ANY ,
8924
+ job_id_prefix = None ,
8925
+ location = self .LOCATION ,
8926
+ project = None ,
8927
+ job_config = mock .ANY ,
8928
+ timeout = DEFAULT_TIMEOUT ,
8929
+ )
8930
+
8931
+ sent_config = load_table_from_file .mock_calls [0 ][2 ]["job_config" ]
8932
+ assert sent_config .source_format == job .SourceFormat .PARQUET
8933
+ assert tuple (sent_config .schema ) == (
8934
+ SchemaField ("x" , "BIGNUMERIC" , "NULLABLE" , None ),
8935
+ )
8936
+
8894
8937
def test_load_table_from_json_basic_use (self ):
8895
8938
from google .cloud .bigquery .client import _DEFAULT_NUM_RETRIES
8896
8939
from google .cloud .bigquery import job
0 commit comments