GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: DB API depends on pyarrow when decimal query parameters are used by plamut · Pull Request #551 · googleapis/python-bigquery

This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Conversation

@plamut

@plamut plamut commented Mar 15, 2021

Copy link
Copy Markdown
Contributor

Fixes #549.

This PR removes the hard dependency of DB API on the optional pyarrow dependency.

PR checklist:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
plamut added 2 commits March 15, 2021 12:36
@plamut
fix: DB API pyarrow dependency with decimal values
4db963c
DB API should gracefully handle the case when the optional pyarrow
dependency is not installed.
@plamut
Blacken DB API helpers tests
24a2992
@plamut
plamut requested review from a team and tswast March 15, 2021 11:44
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 15, 2021
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Mar 15, 2021
plamut
plamut commented Mar 15, 2021
View reviewed changes
Comment thread google/cloud/bigquery/dbapi/_helpers.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

tswast
tswast suggested changes Mar 15, 2021
View reviewed changes

@tswast tswast left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my latest comment, I think we can remove pyarrow entirely from this logic.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut
Refine the logic for recognizing NUMERIC Decimals
de85ca2
plamut
plamut commented Mar 16, 2021
View reviewed changes
Comment thread google/cloud/bigquery/dbapi/_helpers.py
Comment on lines +192 to 201
# NUMERIC values have precision of 38 (number of digits) and scale of 9 (number
# of fractional digits), and their max absolute value must be strictly smaller
# than 1.0E+29.
# https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#decimal_types
if (
len(vtuple.digits) <= 38 # max precision: 38
and vtuple.exponent >= -9 # max scale: 9
and _NUMERIC_SERVER_MIN <= value <= _NUMERIC_SERVER_MAX
):
return "NUMERIC"

@plamut plamut Mar 16, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic differs from the docs, because testing the actual backend response showed that 9.9999999999999999999999999999999999999E+29 is not accepted as a valid NUMERIC value:

SELECT CAST((SELECT "9.9999999999999999999999999999999999999E+29" AS literal) AS NUMERIC);  # error

Even 1.0E+29 is too large, but 9.999...9E+28 works, meaning that there's probably an off-by-one error in the docs for the exponent.

Update: Confirmed, the docs are indeed not correct, an internal issue 182900100 has been created to track this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut
plamut requested review from shollyman and tswast March 16, 2021 10:49
tswast
tswast approved these changes Mar 16, 2021
View reviewed changes

@tswast tswast left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gorgeous!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tswast
tswast merged commit 1b946ba into googleapis:master Mar 16, 2021
gcf-merge-on-green Bot pushed a commit that referenced this pull request Mar 16, 2021
@release-please
chore: release 2.12.0 (#547)
af542f2
🤖 I have created a release \*beep\* \*boop\*
---
## [2.12.0](https://www.github.com/googleapis/python-bigquery/compare/v2.11.0...v2.12.0) (2021-03-16)


### Features

* make QueryJob.done() method more performant ([#544](https://www.github.com/googleapis/python-bigquery/issues/544)) ([a3ab9ef](https://www.github.com/googleapis/python-bigquery/commit/a3ab9efdd0758829845cfcb6ca0ac1f03ab44f64))


### Bug Fixes

* remove DB-API dependency on pyarrow with decimal query parameters ([#551](https://www.github.com/googleapis/python-bigquery/issues/551)) ([1b946ba](https://www.github.com/googleapis/python-bigquery/commit/1b946ba23ee7df86114c6acb338ec34e6c92af6d))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
@plamut
plamut deleted the iss-549 branch March 16, 2021 15:56
plamut
plamut commented Mar 16, 2021
View reviewed changes
Comment thread tests/unit/test_dbapi__helpers.py
self.assertEqual(named_parameter.type_, expected_type, msg=msg)
self.assertEqual(named_parameter.value, value, msg=msg)

def test_decimal_to_query_parameter(self): # TODO: merge with previous test

@plamut plamut Mar 16, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have removed that, it's just a subset of the test_scalar_to_query_parameter test above it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut plamut mentioned this pull request Mar 16, 2021
test: remove duplicate test for Decimal scalars #553
Merged
3 of 4 tasks
This was referenced Mar 17, 2021
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 mozilla/glam#1257
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /requirements fakegit/addons-server#1456
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /requirements mozilla/addons-server#16758
Merged
Bump google-cloud-bigquery from 2.6.1 to 2.12.0 in /requirements diox/olympia#730
Closed
Bump google-cloud-bigquery from 2.1.0 to 2.12.0 in /requirements vishalol/addons-server#517
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /ps2bq braincow/gcp-cloudfunctions#29
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /ruuvitag_trend braincow/gcp-cloudfunctions#30
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 wayfair-incubator/gbq#39
Merged
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /ruuvitag_latest braincow/gcp-cloudfunctions#31
Closed
Bump google-cloud-bigquery from 2.11.0 to 2.12.0 in /ruuvitags braincow/gcp-cloudfunctions#32
Closed
Bump google-cloud-bigquery from 1.6.0 to 2.12.0 in /financial_time_series/tensorflow_model davidspek/examples#110
Closed
chore(deps): bump google-cloud-bigquery from 1.9.0 to 2.12.0 in /components/gcp/container/component_sdk/python davidspek/kfp-tekton#299
Closed
This was referenced Mar 17, 2021
Bump google-cloud-bigquery from 1.9.0 to 2.12.0 in /components/gcp/container/component_sdk/python davidspek/kfp-tekton-backend#371
Closed
Update google-cloud-bigquery requirement from <2.4,>=1.25.0 to >=1.25.0,<2.13 in /plugins/bigquery dbt-labs/dbt#3174
Closed
@release-please release-please Bot mentioned this pull request Jan 4, 2022
chore(main): release python-bigquery 1.27.1 #1097
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 1, 2026
🐛 fix: audit v7 part 3 morzecrew/forze#335
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@shollyman shollyman Awaiting requested review from shollyman
1 more reviewer
@tswast tswast tswast approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

DB-API depends on pyarrow when decimal query parameters are used

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@plamut @tswast
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.