Skip to content

Commit

Permalink
Prevent import time error if no BIGNUMERIC support
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Feb 18, 2021
1 parent 21ae123 commit 7446a92
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions google/cloud/bigquery/_pandas_helpers.py
Expand Up @@ -107,7 +107,6 @@ def pyarrow_timestamp():
"INT64": pyarrow.int64,
"INTEGER": pyarrow.int64,
"NUMERIC": pyarrow_numeric,
"BIGNUMERIC": pyarrow_bignumeric,
"STRING": pyarrow.string,
"TIME": pyarrow_time,
"TIMESTAMP": pyarrow_timestamp,
Expand All @@ -134,10 +133,13 @@ def pyarrow_timestamp():
pyarrow.binary().id: "BYTES",
pyarrow.string().id: "STRING", # also alias for pyarrow.utf8()
pyarrow.decimal128(38, scale=9).id: "NUMERIC",
}

if tuple(map(int, pyarrow.__version__.split("."))) >= (3, 0, 0):
BQ_TO_ARROW_SCALARS["BIGNUMERIC"] = pyarrow_bignumeric
# The exact decimal's scale and precision are not important, as only
# the type ID matters, and it's the same for all decimal128 instances.
pyarrow.decimal256(76, scale=38).id: "BIGNUMERIC",
}
ARROW_SCALAR_IDS_TO_BQ[pyarrow.decimal256(76, scale=38).id] = "BIGNUMERIC"

else: # pragma: NO COVER
BQ_TO_ARROW_SCALARS = {} # pragma: NO COVER
Expand Down

0 comments on commit 7446a92

Please sign in to comment.