@@ -864,6 +864,60 @@ def test_load_table_from_local_avro_file_then_dump_table(self):
864864sorted (row_tuples ,key = by_wavelength ),sorted (ROWS ,key = by_wavelength )
865865 )
866866
867+ def test_load_table_from_local_parquet_file_decimal_types (self ):
868+ from google .cloud .bigquery .enums import DecimalTargetType
869+ from google .cloud .bigquery .job import SourceFormat
870+ from google .cloud .bigquery .job import WriteDisposition
871+
872+ TABLE_NAME = "test_table_parquet"
873+
874+ expected_rows = [
875+ (decimal .Decimal ("123.999999999999" ),),
876+ (decimal .Decimal ("99999999999999999999999999.999999999999" ),),
877+ ]
878+
879+ dataset = self .temp_dataset (_make_dataset_id ("load_local_parquet_then_dump" ))
880+ table_ref = dataset .table (TABLE_NAME )
881+ table = Table (table_ref )
882+ self .to_delete .insert (0 ,table )
883+
884+ job_config = bigquery .LoadJobConfig ()
885+ job_config .source_format = SourceFormat .PARQUET
886+ job_config .write_disposition = WriteDisposition .WRITE_TRUNCATE
887+ job_config .decimal_target_types = [
888+ DecimalTargetType .NUMERIC ,
889+ DecimalTargetType .BIGNUMERIC ,
890+ DecimalTargetType .STRING ,
891+ ]
892+
893+ with open (DATA_PATH / "numeric_38_12.parquet" ,"rb" )as parquet_file :
894+ job = Config .CLIENT .load_table_from_file (
895+ parquet_file ,table_ref ,job_config = job_config
896+ )
897+
898+ job .result (timeout = JOB_TIMEOUT )# Retry until done.
899+
900+ self .assertEqual (job .output_rows ,len (expected_rows ))
901+
902+ table = Config .CLIENT .get_table (table )
903+ rows = self ._fetch_single_page (table )
904+ row_tuples = [r .values ()for r in rows ]
905+ self .assertEqual (sorted (row_tuples ),sorted (expected_rows ))
906+
907+ # Forcing the NUMERIC type, however, should result in an error.
908+ job_config .decimal_target_types = [DecimalTargetType .NUMERIC ]
909+
910+ with open (DATA_PATH / "numeric_38_12.parquet" ,"rb" )as parquet_file :
911+ job = Config .CLIENT .load_table_from_file (
912+ parquet_file ,table_ref ,job_config = job_config
913+ )
914+
915+ with self .assertRaises (BadRequest )as exc_info :
916+ job .result (timeout = JOB_TIMEOUT )
917+
918+ exc_msg = str (exc_info .exception )
919+ self .assertIn ("out of valid NUMERIC range" ,exc_msg )
920+
867921def test_load_table_from_json_basic_use (self ):
868922table_schema = (
869923bigquery .SchemaField ("name" ,"STRING" ,mode = "REQUIRED" ),