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 — feat: add `api_method` parameter to `Client.query` to select `INSERT` or `QUERY` API by tswast · Pull Request #967 · googleapis/python-bigquery

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

Conversation

@tswast

@tswast tswast commented Sep 13, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This PR is the first step in enabling the "fast query path". At the moment, selecting api_method="QUERY" is actually likely to be slower because it fetches the first page of results and discards them. A PR will follow-up to cache this first page for use by the row iterator.

This commit only refactors to allow jobs.insert to be selected.
Supporting jobs.query will require more transformations to QueryJobConfig,
QueryJob, and RowIterator.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • 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)

Towards #589 🦕

Sorry, something went wrong.

Uh oh!

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

All reactions
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 13, 2021
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Sep 13, 2021
tswast
tswast commented Sep 14, 2021
View reviewed changes
Comment thread google/cloud/bigquery/_job_helpers.py Resolved

Uh oh!

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

@tswast

tswast commented Sep 17, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

Even though this isn't a breaking change, it refactors enough that maybe this should target v3 so as not to delay v3 any longer.

All reactions

Sorry, something went wrong.

Uh oh!

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

@tswast
tswast changed the base branch from main to v3 October 5, 2021 15:41
@snippet-bot

snippet-bot Bot commented Oct 5, 2021 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

No region tags are edited in this PR.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment
All reactions

Sorry, something went wrong.

Uh oh!

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

@google-cla google-cla Bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Oct 5, 2021
@tswast tswast changed the title feat: add api_method parameter to Client.query to select insert or query API feat: add api_method parameter to Client.query to select INSERT or QUERY API Oct 6, 2021
@google-cla

This comment has been minimized.

Sign in to view
tswast added 7 commits October 7, 2021 16:43
@tswast
feat: add api_method parameter to Client.query to select insert…
575966d
… or `query` API

Work in Progress. This commit only refactors to allow jobs.insert to be selected.
Supporting jobs.query will require more transformations to QueryJobConfig,
QueryJob, and RowIterator.
@tswast
WIP: begin implementation of jobs.query usage
094e3cb
@tswast
remove extra files
17994f5
@tswast
insert query with jobs.query
c963e25
@tswast
fix merge between job config and query request
5093378
@tswast
add tests
e2e1c7d
@tswast
update todo with thoughts on future perf update
2e4af92
@tswast
tswast force-pushed the issue589-queries-endpoint branch from 7b9457c to 2e4af92 Compare October 7, 2021 21:43
@googleapis googleapis deleted a comment from google-cla Bot Oct 7, 2021
@google-cla google-cla Bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Oct 7, 2021
@googleapis googleapis deleted a comment from google-cla Bot Oct 7, 2021
@googleapis googleapis deleted a comment from google-cla Bot Oct 7, 2021
@googleapis googleapis deleted a comment from google-cla Bot Oct 7, 2021
tswast added 3 commits October 7, 2021 16:49
@tswast
clarify TODO comment
d700df5
@tswast
add placeholders for needed tests
1e73a56
@tswast
add schema property
7435c8d
@tswast tswast mentioned this pull request Oct 11, 2021
feat: add QueryJob.schema property for dry run queries #1014
Merged
4 tasks
tswast added 2 commits October 12, 2021 10:33
@tswast
feat: add QueryJob.schema property for dry run queries
d383847
@tswast
add more job properties
8bc2458
@tswast
tswast requested review from a team and loferris November 18, 2021 23:05
@tswast

tswast commented Nov 18, 2021

Copy link
Copy Markdown
Contributor Author

I've just synced to the latest v3 branch. Unit tests and query system tests are passing. I think this is ready for review.

Note: This won't actually result in any performance improvements until the # TODO: https://github.com/googleapis/python-bigquery/issues/589 in _job_helpers.py is resolved. Since that requires more hacks to the QueryJob class, I figure that's worth postponing to a separate PR. As-is, this PR should be showing the same behavior for api_method="INSERT" and api_method="QUERY" options.

All reactions

Sorry, something went wrong.

Uh oh!

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

@tswast

This comment has been minimized.

Sign in to view
@tswast

This comment has been minimized.

Sign in to view
tswast added 2 commits November 19, 2021 09:51
@tswast
adjust query job construction
0598ace
@tswast
avoid conflicting table IDs
4f36bae
tswast
tswast commented Nov 19, 2021
View reviewed changes
Comment thread tests/system/conftest.py Resolved

Uh oh!

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

@tswast
mock query response
3058498
@tswast
tswast requested a review from plamut November 19, 2021 16:25
@tswast

This comment has been minimized.

Sign in to view
tswast added 3 commits November 19, 2021 14:12
@tswast
fix unit test coverage
ba785d9
@tswast
fix type errors
b67ac5a
@tswast
fix docs formatting
a3223b1
plamut
plamut reviewed Nov 20, 2021
View reviewed changes

@plamut plamut 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.

Looks really promising and structured, mostly just minor remarks and questions.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/cloud/bigquery/_job_helpers.py Resolved

Uh oh!

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

Comment thread google/cloud/bigquery/_job_helpers.py Resolved

Uh oh!

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

Comment thread google/cloud/bigquery/_job_helpers.py Resolved

Uh oh!

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

Comment thread tests/system/test_query.py Resolved

Uh oh!

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

Comment thread tests/system/test_query.py Resolved

Uh oh!

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

Comment thread tests/unit/test__job_helpers.py Resolved

Uh oh!

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

@tswast
comments and additional unit tests
b257609
@tswast
tswast requested a review from plamut November 22, 2021 16:54
plamut
plamut approved these changes Nov 22, 2021
View reviewed changes

@plamut plamut 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.

LGTM.

There's one nit, but decide for yourself if it's worth updating the PR.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/cloud/bigquery/client.py
called on the job returned. The ``job_retry``
specified here becomes the default ``job_retry`` for
``result()``, where it can also be specified.
api_method (Union[str, enums.QueryApiMethod]):

@plamut plamut Nov 22, 2021

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.

(nit) Duplicate annotation info

Sorry, something went wrong.

Uh oh!

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

All reactions
loferris
loferris approved these changes Nov 29, 2021
View reviewed changes

@loferris loferris 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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@tswast
tswast merged commit 3b3ebff into googleapis:v3 Dec 2, 2021
@tswast
tswast deleted the issue589-queries-endpoint branch December 2, 2021 20:15
@tswast tswast mentioned this pull request Mar 29, 2022
fix!: remove out-of-date BigQuery ML protocol buffers #1178
Merged
4 tasks
tswast added a commit that referenced this pull request Mar 29, 2022
@tswast
fix!: remove out-of-date BigQuery ML protocol buffers (#1178)
76d88fb
deps!: BigQuery Storage and pyarrow are required dependencies (#776)

fix!: use nullable `Int64` and `boolean` dtypes in `to_dataframe` (#786) 

feat!: destination tables are no-longer removed by `create_job` (#891)

feat!: In `to_dataframe`, use `dbdate` and `dbtime` dtypes from db-dtypes package for BigQuery DATE and TIME columns (#972)

fix!: automatically convert out-of-bounds dates in `to_dataframe`, remove `date_as_object` argument (#972)

feat!: mark the package as type-checked (#1058)

feat!: default to DATETIME type when loading timezone-naive datetimes from Pandas (#1061)

feat: add `api_method` parameter to `Client.query` to select `INSERT` or `QUERY` API (#967)

fix: improve type annotations for mypy validation (#1081)

feat: use `StandardSqlField` class for `Model.feature_columns` and `Model.label_columns` (#1117)

docs: Add migration guide from version 2.x to 3.x (#1027)

Release-As: 3.0.0
@release-please release-please Bot mentioned this pull request Mar 29, 2022
chore(main): release 3.0.0 #1179
Merged
waltaskew pushed a commit to waltaskew/python-bigquery that referenced this pull request Jul 20, 2022
@tswast @waltaskew
fix!: remove out-of-date BigQuery ML protocol buffers (googleapis#1178)
e049810
deps!: BigQuery Storage and pyarrow are required dependencies (googleapis#776)

fix!: use nullable `Int64` and `boolean` dtypes in `to_dataframe` (googleapis#786) 

feat!: destination tables are no-longer removed by `create_job` (googleapis#891)

feat!: In `to_dataframe`, use `dbdate` and `dbtime` dtypes from db-dtypes package for BigQuery DATE and TIME columns (googleapis#972)

fix!: automatically convert out-of-bounds dates in `to_dataframe`, remove `date_as_object` argument (googleapis#972)

feat!: mark the package as type-checked (googleapis#1058)

feat!: default to DATETIME type when loading timezone-naive datetimes from Pandas (googleapis#1061)

feat: add `api_method` parameter to `Client.query` to select `INSERT` or `QUERY` API (googleapis#967)

fix: improve type annotations for mypy validation (googleapis#1081)

feat: use `StandardSqlField` class for `Model.feature_columns` and `Model.label_columns` (googleapis#1117)

docs: Add migration guide from version 2.x to 3.x (googleapis#1027)

Release-As: 3.0.0
abdelmegahedgoogle pushed a commit to abdelmegahedgoogle/python-bigquery that referenced this pull request Apr 17, 2023
@tswast @abdelmegahedgoogle
feat: add QueryJob.schema property for dry run queries (googleapis#…
d843100
…1014)

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery/issues/new/choose) 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)

Issue discovered while investigating what properties are needed in googleapis#967
abdelmegahedgoogle pushed a commit to abdelmegahedgoogle/python-bigquery that referenced this pull request Apr 17, 2023
@tswast @abdelmegahedgoogle
fix!: remove out-of-date BigQuery ML protocol buffers (googleapis#1178)
6ec1bf3
deps!: BigQuery Storage and pyarrow are required dependencies (googleapis#776)

fix!: use nullable `Int64` and `boolean` dtypes in `to_dataframe` (googleapis#786) 

feat!: destination tables are no-longer removed by `create_job` (googleapis#891)

feat!: In `to_dataframe`, use `dbdate` and `dbtime` dtypes from db-dtypes package for BigQuery DATE and TIME columns (googleapis#972)

fix!: automatically convert out-of-bounds dates in `to_dataframe`, remove `date_as_object` argument (googleapis#972)

feat!: mark the package as type-checked (googleapis#1058)

feat!: default to DATETIME type when loading timezone-naive datetimes from Pandas (googleapis#1061)

feat: add `api_method` parameter to `Client.query` to select `INSERT` or `QUERY` API (googleapis#967)

fix: improve type annotations for mypy validation (googleapis#1081)

feat: use `StandardSqlField` class for `Model.feature_columns` and `Model.label_columns` (googleapis#1117)

docs: Add migration guide from version 2.x to 3.x (googleapis#1027)

Release-As: 3.0.0
@davidkell davidkell mentioned this pull request Dec 19, 2023
Postgres gyana/gyana#1494
Merged
24 of 25 tasks
@tswast tswast mentioned this pull request Apr 13, 2024
fix: avoid unnecessary API call in QueryJob.result() when job is already finished #1900
Merged
4 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@plamut plamut plamut approved these changes
@loferris loferris loferris 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.

Provide support for synchronous queries through the v2/projects/{projectId}/queries endpoint

Uh oh!

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

3 participants

@tswast @plamut @loferris
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.