Skip to content

Commit a662beb

Browse files
committed
fix test_load_table_from_dataframe_w_higher_scale_decimal128_datatype
1 parent 47f5096 commit a662beb

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

google/cloud/bigquery/_pandas_helpers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import warnings
2424
from typing import Any, Union
2525

26+
2627
from google.cloud.bigquery import _pyarrow_helpers
2728
from google.cloud.bigquery import _versions_helpers
2829
from google.cloud.bigquery import schema
@@ -485,7 +486,6 @@ def augment_schema(dataframe, current_bq_schema):
485486
# pytype: disable=attribute-error
486487
augmented_schema = []
487488
unknown_type_fields = []
488-
489489
for field in current_bq_schema:
490490
if field.field_type is not None:
491491
augmented_schema.append(field)
@@ -515,9 +515,7 @@ def augment_schema(dataframe, current_bq_schema):
515515
else:
516516
detected_mode = field.mode
517517
detected_type = _pyarrow_helpers.arrow_scalar_ids_to_bq(arrow_table.type.id)
518-
if detected_type == "NUMERIC" and (
519-
arrow_table.type.precision > 38 or arrow_table.type.scale > 9
520-
):
518+
if detected_type == "NUMERIC" and arrow_table.type.scale > 9:
521519
detected_type = "BIGNUMERIC"
522520

523521
if detected_type is None:

tests/unit/test_client.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8900,24 +8900,14 @@ def test_load_table_from_dataframe_w_higher_scale_decimal128_datatype(self):
89008900
from decimal import Decimal
89018901

89028902
client = self._make_client()
8903-
dataframe = pandas.DataFrame(
8904-
{
8905-
"x": [
8906-
Decimal("0.12345678901234560000000000000000000000"),
8907-
Decimal("01234567890123456789012345678901234567.1234567891"),
8908-
]
8909-
}
8910-
)
8903+
dataframe = pandas.DataFrame({"x": [Decimal("0.1234567891")]})
89118904
load_patch = mock.patch(
89128905
"google.cloud.bigquery.client.Client.load_table_from_file", autospec=True
89138906
)
89148907

89158908
get_table_patch = mock.patch(
8916-
"google.cloud.bigquery.client.Client.get_table",
8917-
autospec=True,
8918-
return_value=mock.Mock(schema=[SchemaField("x", "BIGNUMERIC", "NULLABLE")]),
8909+
"google.cloud.bigquery.client.Client.get_table", autospec=True
89198910
)
8920-
89218911
with load_patch as load_table_from_file, get_table_patch:
89228912
client.load_table_from_dataframe(
89238913
dataframe, self.TABLE_REF, location=self.LOCATION

0 commit comments

Comments
 (0)