Add biquery query parameter option to support parametrize query - #39389
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enables parameterized queries for BigQueryIO in the Go SDK. By allowing users to pass query parameters, it improves security and flexibility when interacting with BigQuery. The changes include the necessary infrastructure to serialize these parameters for execution within the Beam pipeline, alongside updates to integration test utilities to better support project-specific configurations. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for parameterized queries in the Go SDK's BigQuery IO connector, adding a new WithQueryParameters option, serializing parameters during pipeline execution, and updating integration tests. The reviewer feedback is highly constructive and identifies critical issues: JSON serialization will cause type loss for query parameters (e.g., converting integers to floats), which can be resolved by using gob encoding; decoding will fail on empty parameters without a guard check; tests should be expanded to cover numeric types; and encoding should be skipped when no parameters are provided to avoid overhead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Assigning reviewers: R: @lostluck for label go. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
QueryParameter and QueryParameterValue contains filed with any type. Converting go types to encoding/json lose type informations some of go types. The registered types are ones supported in the implementation in paramValue method. https://github.com/googleapis/google-cloud-go/blob/bigquery/v1.79.0/bigquery/params.go#L434
5875abd to
c4675c6
Compare
|
Reminder, please take a look at this pr: @lostluck |
|
|
||
| "TestTimers_EventTime_WithNoOutputTimestamp", // Encounter error: TimestampCombiner moved element from TIMESTAMP_MAX_VALUE to earlier time (end of global window) for window GlobalWindow | ||
| "TestTimers_ProcessingTime.*", // Flink doesn't support processing time timers. | ||
| "TestTimers_ProcessingTime.*", // Flink doesn't support processing time timers. |
There was a problem hiding this comment.
Errant formatting change?
There was a problem hiding this comment.
Thank you for reviewing!
I ran go fmt against this file. The formatting matches go fmt.
As far as I can tell, go fmt runs only against sdks/go/pkg/beam in CI: https://github.com/apache/beam/blob/master/.github/workflows/go_tests.yml#L61
I can do either
- (1) Revert this formatting
- (2) Or create another issue and a dedicated PR to update the go fmt check to include all Go files
There was a problem hiding this comment.
Gofmt aligns comments vertically when part of consecutive lines in the same block, so the new formatting is correct. I wouldn't worry about trying to fix it.
lostluck
left a comment
There was a problem hiding this comment.
LGTM. Just one typo fix. I'd make it myself but I'm phone only at the moment.
| if params == nil { | ||
| return []byte{}, nil | ||
| } | ||
| // validate each element to tell which paramaeter is unsupported. |
Fix typo
Addresses: #29382
Also addresses: #25096
Description
This PR supports QueryParameter for BigQueryIO in Go.
The type of bigquery.QueryParameter.Value is any so encoding/decoding should preserve the types in any.
To preserve type information, I've implemented it with encoding/gob under the following limitations:
type Counter int64)bbigquery.QueryParameter.Value supports both types. See https://github.com/googleapis/google-cloud-go/blob/bigquery/v1.79.0/bigquery/params.go#L323.
Another possible approach is to implement a similar conversion logic to that implemented in paramValue by converting user-defined types to bigquery.QueryParameterValue explicitly.
This solution requires us to maintain the same conversion logic defined internally in the bigquery pkg. This seems over-complicated for now. But we can extend the implementation to add the conversion logic in the encodeQueryParameter function later.
Tests
I successfully ran integrated tests with
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.