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 support for INTERVAL data type to `list_rows` by tswast · Pull Request #840 · googleapis/python-bigquery

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

Conversation

@tswast

@tswast tswast commented Jul 29, 2021

Copy link
Copy Markdown
Contributor

Implementation of most other features for INTERVAL is blocked by backend changes.

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 googleapis/google-cloud-python#15740 🦕

Sorry, something went wrong.

Uh oh!

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

All reactions
tswast added 8 commits July 28, 2021 14:58
@tswast
test: refactor list_rows tests and add test for scalars
5704f1e
@tswast
WIP: INTERVAL support
5eb3794
@tswast
feat: add support for INTERVAL data type to list_rows
9e54277
@tswast
Merge remote-tracking branch 'upstream/master' into issue826-interval
a89c1c1
@tswast
fix relativedelta construction for non-microseconds
60d9ca7
@tswast
WIP: support INTERVAL query params
da6ef5b
@tswast
remove dead code
b73a610
@tswast
INTERVAL not supported in query parameters
52f2b7b
@tswast
tswast requested review from a team and stephaniewang526 and removed request for a team July 29, 2021 22:12
@product-auto-label product-auto-label Bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Jul 29, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 29, 2021
@tswast
Merge remote-tracking branch 'upstream/master' into issue826-interval
ca8872e
@tswast tswast added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jul 29, 2021
@tswast

tswast commented Jul 29, 2021

Copy link
Copy Markdown
Contributor Author

Some of these commits are from #829

All reactions

Sorry, something went wrong.

Uh oh!

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

@tswast tswast mentioned this pull request Mar 2, 2026
Support INTERVAL data type googleapis/google-cloud-python#15740
Open
4 tasks
jimfulton
jimfulton reviewed Jul 30, 2021
View reviewed changes
Comment thread google/cloud/bigquery/_helpers.py Resolved

Uh oh!

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

Comment thread google/cloud/bigquery/_helpers.py Outdated
minutes = time_sign * int(parsed.group("minutes"))
seconds = time_sign * int(parsed.group("seconds"))
fraction = parsed.group("fraction")
microseconds = time_sign * int(fraction.ljust(6, "0")) if fraction else 0

@jimfulton jimfulton Jul 30, 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.

I can't tell from https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#interval_type if there are limits on any of these fields. 🤷

Sorry, something went wrong.

Uh oh!

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

All reactions

@tswast tswast Aug 5, 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 agree. The docs don't really explain much about how this data format actually works. From what is documented and trial and error, I think these are the limits:

Min

  • years: -10000
  • months: -11 (I think?)
  • days: -3660000
  • hours: -87840000
  • minutes: -59 (I think?)
  • seconds: -59 (I think?)
  • microseconds: -999999 (I think?)

Max

  • years: 10000
  • months: 11 (I think?)
  • days: 3660000
  • hours: 87840000
  • minutes: 59 (I think?)
  • seconds: 59 (I think?)
  • microseconds: 999999 (I think?)

I don't think we'll need any client-side validation for this, but it does remind me that we should have some unit tests that exercise these limits.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/cloud/bigquery/enums.py
Comment on lines +263 to +279
BOOL = ScalarQueryParameterType("BOOL")
BOOLEAN = ScalarQueryParameterType("BOOL")
BIGDECIMAL = ScalarQueryParameterType("BIGNUMERIC")
BIGNUMERIC = ScalarQueryParameterType("BIGNUMERIC")
BYTES = ScalarQueryParameterType("BYTES")
INTEGER = ScalarQueryParameterType("INT64")
INT64 = ScalarQueryParameterType("INT64")
DATE = ScalarQueryParameterType("DATE")
DATETIME = ScalarQueryParameterType("DATETIME")
DECIMAL = ScalarQueryParameterType("NUMERIC")
FLOAT = ScalarQueryParameterType("FLOAT64")
FLOAT64 = ScalarQueryParameterType("FLOAT64")
NUMERIC = ScalarQueryParameterType("NUMERIC")
BIGNUMERIC = ScalarQueryParameterType("BIGNUMERIC")
DECIMAL = ScalarQueryParameterType("NUMERIC")
BIGDECIMAL = ScalarQueryParameterType("BIGNUMERIC")
BOOLEAN = ScalarQueryParameterType("BOOL")
BOOL = ScalarQueryParameterType("BOOL")
GEOGRAPHY = ScalarQueryParameterType("GEOGRAPHY")
TIMESTAMP = ScalarQueryParameterType("TIMESTAMP")
DATE = ScalarQueryParameterType("DATE")
INT64 = ScalarQueryParameterType("INT64")
INTEGER = ScalarQueryParameterType("INT64")
NUMERIC = ScalarQueryParameterType("NUMERIC")
STRING = ScalarQueryParameterType("STRING")
TIME = ScalarQueryParameterType("TIME")
DATETIME = ScalarQueryParameterType("DATETIME")
TIMESTAMP = ScalarQueryParameterType("TIMESTAMP")

@jimfulton jimfulton Jul 30, 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.

Did you intend to include INTERVAL?

Sorry, something went wrong.

Uh oh!

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

All reactions

@tswast tswast Aug 3, 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 did but then reverted it because the query parameter support is incomplete. I could revert the alphabetization, but I figure we should do that at some point.

Sorry, something went wrong.

Uh oh!

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

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

Uh oh!

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

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

Uh oh!

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

tswast added 4 commits August 3, 2021 11:10
@tswast
Merge branch 'master' into issue826-interval
018a617
@tswast
Merge remote-tracking branch 'upstream/master' into issue826-interval
2872d85
@tswast
revert query parameter changes
31c3f92
@tswast
Merge remote-tracking branch 'origin/issue826-interval' into issue826…
e3a3a6a
…-interval
@plamut plamut mentioned this pull request Aug 4, 2021
feat: support ScalarQueryParameterType for type_ argument in ScalarQueryParameter constructor #850
Merged
4 tasks
tswast added 3 commits August 5, 2021 16:07
@tswast
Merge branch 'master' into issue826-interval
5f78311
@tswast
add validation error for interval
bb03618
@tswast
add unit tests for extreme intervals
f3711e7
@tswast

tswast commented Aug 5, 2021

Copy link
Copy Markdown
Contributor Author

I think this is ready, but I'll keep the Do Not Merge label, as I think #829 should go in first.

All reactions

Sorry, something went wrong.

Uh oh!

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

tswast
tswast commented Aug 11, 2021
View reviewed changes
Comment thread docs/conf.py Resolved

Uh oh!

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

@tswast
add dateutil to intersphinx
68035ba
@tswast tswast mentioned this pull request Sep 30, 2021
potential rounding error with use of divmod googleapis/python-db-dtypes-pandas#18
Closed
tswast added 2 commits September 30, 2021 13:32
@tswast
add test case for trailing .
0497b19
@tswast
Merge remote-tracking branch 'origin/issue826-interval' into issue826…
92f41b9
…-interval
@tswast
tswast requested review from plamut and removed request for jimfulton September 30, 2021 18:38
@tswast
explicit none
0318f54
@tswast tswast added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 30, 2021
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 30, 2021
gcf-owl-bot Bot and others added 6 commits September 30, 2021 18:44
@gcf-owl-bot
🦉 Updates from OwlBot
6b1f238
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
@tswast
truncate nanoseconds
54e47f7
@tswast
Merge remote-tracking branch 'origin/issue826-interval' into issue826…
ced356b
…-interval
@tswast
use \d group for digits
dcc8b57
@tswast
Merge branch 'main' into issue826-interval
5c31fe2
@tswast
Merge branch 'main' into issue826-interval
2091478
@tswast tswast added the owlbot:run Add this label to trigger the Owlbot post processor. label Oct 25, 2021
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Oct 25, 2021
@tswast

tswast commented Oct 25, 2021

Copy link
Copy Markdown
Contributor Author

@plamut Did you have any additional thoughts on this? It'd be good to get in before v3. I added some proposed unit tests with trailing ., but kept the regex for separating seconds from microseconds due to rounding errors discovered with the divmod approach.

All reactions

Sorry, something went wrong.

Uh oh!

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

@plamut
Merge branch 'main' into issue826-interval
21a2975
plamut
plamut reviewed Oct 26, 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.

Went over this again, it looks fine (just one nit).

Good that we caught the issue in the divmod-based implementation, keeping the regex is the right way to go.

Sorry, something went wrong.

Uh oh!

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

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

Uh oh!

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

tswast added 3 commits October 26, 2021 10:09
@tswast
Merge remote-tracking branch 'upstream/main' into issue826-interval
87b0d81
@tswast
Merge remote-tracking branch 'origin/issue826-interval' into issue826…
7bd48be
…-interval
@tswast
use \d for consistency
d62b950
@tswast
tswast requested a review from plamut October 26, 2021 15:20
plamut
plamut approved these changes Oct 26, 2021
View reviewed changes
@tswast tswast added the automerge Merge the pull request once unit tests and other checks pass. label Oct 26, 2021
@tswast
tswast merged commit e37380a into googleapis:main Oct 26, 2021
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Oct 26, 2021
@tswast
tswast deleted the issue826-interval branch October 26, 2021 16:04
@release-please release-please Bot mentioned this pull request Jan 4, 2022
chore(main): release python-bigquery 1.27.1 #1097
Closed
abdelmegahedgoogle pushed a commit to abdelmegahedgoogle/python-bigquery that referenced this pull request Apr 17, 2023
@tswast @gcf-owl-bot
@plamut @abdelmegahedgoogle
feat: add support for INTERVAL data type to list_rows (googleapis#840)
ebce5ec
* test: refactor `list_rows` tests and add test for scalars

* WIP: INTERVAL support

* feat: add support for INTERVAL data type to `list_rows`

* fix relativedelta construction for non-microseconds

* WIP: support INTERVAL query params

* remove dead code

* INTERVAL not supported in query parameters

* revert query parameter changes

* add validation error for interval

* add unit tests for extreme intervals

* add dateutil to intersphinx

* use dictionary for intersphinx

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* add test case for trailing .

* explicit none

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* truncate nanoseconds

* use \d group for digits

* use \d for consistency

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Peter Lamut <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@stephaniewang526 stephaniewang526 Awaiting requested review from stephaniewang526
2 more reviewers
@jimfulton jimfulton jimfulton left review comments
@plamut plamut plamut 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.

Uh oh!

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

3 participants

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