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: handle case when expirationMs is None by abdelmegahed · Pull Request #1553 · googleapis/python-bigquery

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

Conversation

@abdelmegahed

@abdelmegahed abdelmegahed commented Apr 17, 2023

Copy link
Copy Markdown
Contributor

Right now, unsetting ['timePartitioning']['expirationMs'] on BigQuery table is not supported and raises google.api_core.exceptions.BadRequest: 400 PATCH https://bigquery.googleapis.com/bigquery/v2/projects/abdelrahmanm-bd-dev/datasets/partition_expiry_test/tables/sample_data_partitioned?prettyPrint=false: Invalid value at 'table.time_partitioning.expiration_ms.value' (TYPE_INT64), "None"

This happens since the backend doesn't treat "None" (string) as a null. This PR addresses this issue from the client side.

Sample code that fails with the above exception:

from google.cloud import bigquery
client = bigquery.Client(project='abdelrahmanm-bd-dev')
table_ref = client.dataset('partition_expiry_test').table('sample_data_partitioned')
table = client.get_table(table_ref)
table.partition_expiration = None # ISSUE HERE!! This get cast to string and the backend returns a 400 as a result.
client.update_table(table, ['partition_expiration'])

Sorry, something went wrong.

Uh oh!

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

All reactions
@abdelmegahed
hotfix: handle case when expirationMs is None
52d9f76
@abdelmegahed
abdelmegahed requested review from a team and rosiezou April 17, 2023 20:16
@product-auto-label product-auto-label Bot added size: xs Pull request size is extra small. api: bigquery Issues related to the googleapis/python-bigquery API. labels Apr 17, 2023
@abdelmegahed abdelmegahed mentioned this pull request Apr 17, 2023
bug: handle case when expirationMs is None #1551
Closed
@tswast
Merge branch 'main' into support_partition_expiration_none_value
d3ae7aa
tswast
tswast suggested changes Apr 18, 2023
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.

Thanks @abdelmegahed

Could you write a unit test covering this case? I'd expect one similar to https://github.com/googleapis/python-bigquery/blob/main/tests/unit/test_table.py#L1178 test_to_api_repr_w_custom_field perhaps called test_to_api_repr_w_unsetting_expiration

Sorry, something went wrong.

Uh oh!

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

All reactions
@abdelmegahed
Add test for unsetting table exp
52d12e6
@product-auto-label product-auto-label Bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Apr 18, 2023
@abdelmegahed

abdelmegahed commented Apr 18, 2023

Copy link
Copy Markdown
Contributor Author

@tswast test added. Thanks for the pointers :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@abdelmegahed
abdelmegahed requested a review from tswast April 18, 2023 21:54
@tswast tswast added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 18, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 18, 2023
tswast
tswast reviewed Apr 18, 2023
View reviewed changes
Comment thread tests/unit/test_table.py Resolved

Uh oh!

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

@tswast
Update tests/unit/test_table.py
ec3b22d
@tswast tswast added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 18, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 18, 2023
@abdelmegahed
Update exp_resource for the unsetting_exp test
361c1dd
@abdelmegahed
abdelmegahed requested a review from tswast April 19, 2023 00:05
tswast
tswast approved these changes May 16, 2023
View reviewed changes
@tswast tswast changed the title hotfix: handle case when expirationMs is None fix: handle case when expirationMs is None May 16, 2023
@tswast
Merge branch 'main' into support_partition_expiration_none_value
54fe087
@tswast tswast added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels May 16, 2023
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 16, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 16, 2023
@tswast
tswast merged commit fa6e13d into googleapis:main May 17, 2023
@release-please release-please Bot mentioned this pull request May 17, 2023
chore(main): release 3.11.0 #1568
Merged
This was referenced Jun 13, 2023
June 05, 2023 kitta65/bq-extension-vscode#194
Closed
June 05, 2023 kitta65/prettier-plugin-bq#201
Closed
June 05, 2023 kitta65/bq2cst#213
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@rosiezou rosiezou Awaiting requested review from rosiezou
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. size: s Pull request size is small.

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

@abdelmegahed @tswast @yoshi-kokoro
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.