Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

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

feat: support RANGE query parameters#1827

Merged
Linchin merged 14 commits into
googleapis:maingoogleapis/python-bigquery:mainfrom
Linchin:range-query-paramsLinchin/python-bigquery:range-query-paramsCopy head branch name to clipboard
Mar 4, 2024
Merged

feat: support RANGE query parameters#1827
Linchin merged 14 commits into
googleapis:maingoogleapis/python-bigquery:mainfrom
Linchin:range-query-paramsLinchin/python-bigquery:range-query-paramsCopy head branch name to clipboard

Conversation

@Linchin

@Linchin Linchin commented Feb 23, 2024

Copy link
Copy Markdown
Contributor

Part of #1724.

In this PR, we add support for using a query parameter of RANGE type, either named or positional. Here is an example below:

from google.cloud import bigquery
from datetime import datetime, date

# Construct a BigQuery client object.
client = bigquery.Client()

query = """SELECT ? AS foo"""


# Set the name to None to use positional parameters.
# Note that you cannot mix named and positional parameters.
job_config = bigquery.QueryJobConfig(
    query_parameters=[
        bigquery.RangeQueryParameter("DATETIME", start=datetime(year=2020, month=10, day=30), end=None),
    ]
)

results = client.query_and_wait(query, job_config=job_config) 

for row in results:
    print(row)

More specifically:

  • Added classes RangeQueryParameter, RangeQueryParameterType and their corresponding methods
  • Added unit tests
  • Added system tests

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 #1724 🦕

@Linchin Linchin requested review from a team February 23, 2024 22:50
@product-auto-label product-auto-label Bot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/python-bigquery API. labels Feb 23, 2024
@Linchin Linchin added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 23, 2024
@Linchin Linchin removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 24, 2024
@Linchin Linchin added kokoro:force-run Add this label to force Kokoro to re-run the tests. do not merge Indicates a pull request not ready for merge, due to either quality or timing. kokoro:run Add this label to force Kokoro to re-run the tests. and removed kokoro:force-run Add this label to force Kokoro to re-run the tests. do not merge Indicates a pull request not ready for merge, due to either quality or timing. kokoro:run Add this label to force Kokoro to re-run the tests. labels Feb 24, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 26, 2024
@chalmerlowe

Copy link
Copy Markdown
Collaborator

@Linchin please fill out the description of this PR so that reviewers and "future us" can quickly identify the purpose and scope of this change. Thanks.

@Linchin

Linchin commented Feb 27, 2024

Copy link
Copy Markdown
Contributor Author

Thanks @chalmerlowe! Definitely got lost in the work and forgot to add the description. I just edited it to add more details :)

Comment thread google/cloud/bigquery/query.py Outdated
Comment thread google/cloud/bigquery/query.py Outdated
Comment thread tests/unit/test_query.py Outdated
),
(
"SELECT @range_date",
"[2016-12-05, UNBOUNDED)",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is 'UNBOUNDED' some kind of type alias, or does the service return that as the literal string? If so, should we convert UNBOUNDED -> None when build query parameter values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The service returns 'UNBOUNDED' as part of the literal string. 'UNBOUNDED' isn't an alias of any type, so it's safe to convert it into None.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Its fine to punt on this aspect, I just wanted to clarify.

),
(
"SELECT @range_date",
"[2016-12-05, UNBOUNDED)",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Its fine to punt on this aspect, I just wanted to clarify.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.