Skip to content

fix(tool/bigquery): handle omitted optional parameters with typed NULLs#3051

Merged
duwenxin99 merged 4 commits into
googleapis:mainfrom
Deeven-Seru:fix-3033-bq-optional-parameters
May 7, 2026
Merged

fix(tool/bigquery): handle omitted optional parameters with typed NULLs#3051
duwenxin99 merged 4 commits into
googleapis:mainfrom
Deeven-Seru:fix-3033-bq-optional-parameters

Conversation

@Deeven-Seru
Copy link
Copy Markdown
Contributor

Description

This PR fixes a runtime bigquery: nil parameter error that occurred when optional parameters were omitted in BigQuery tool calls. The issue was caused by the tool sending untyped nil values to the BigQuery API, which the SDK does not accept for parameters.

Impact:

  • Resolves crashes when executing queries with omitted optional parameters.
  • Enables the use of IS NULL logic and optional filters in BigQuery SQL statements.

Summary of Solution:

  • Typed NULL Mapping: Refactored parameter processing to map tool-level nil values to specific BigQuery SDK types (NullString, NullInt64, NullFloat64, NullBool).
  • REST API Support: Implemented NullFields handling for the low-level REST client to ensure NULL values are correctly marshaled during dry runs.
  • Array Support: Added handling for typed nil slices for array parameters to ensure alignment with standard SQL expectations.
  • Verification: Added comprehensive unit tests in bigquerysql_invoke_test.go to validate mapping for all supported scalar and collection types.

PR Checklist

  • Make sure you reviewed CONTRIBUTING.md
  • Make sure to open an issue as a bug/issue before writing your code!
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #3033

@Deeven-Seru Deeven-Seru requested review from a team as code owners April 14, 2026 07:27
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the BigQuery SQL tool to better handle optional parameters and NULL values by introducing a dedicated buildQueryParameters function. It also adds comprehensive unit tests for parameter building. The review feedback correctly identifies a potential issue with named parameter detection using simple string containment, which could lead to false positives, and suggests handling the TypeMap parameter type to prevent potential nil pointer issues.

Comment thread internal/tools/bigquery/bigquerysql/bigquerysql.go Outdated
Comment thread internal/tools/bigquery/bigquerysql/bigquerysql.go Outdated
@Deeven-Seru Deeven-Seru force-pushed the fix-3033-bq-optional-parameters branch from 5a7e82b to b667ac0 Compare April 21, 2026 16:24
@Yuan325 Yuan325 added the product: bigquery BigQuery label Apr 28, 2026
@Yuan325 Yuan325 removed their assignment Apr 28, 2026
@Yuan325 Yuan325 added the blunderbuss: assign Have blunderbuss assign this to someone new. label Apr 28, 2026
@blunderbuss-gcf blunderbuss-gcf Bot removed the blunderbuss: assign Have blunderbuss assign this to someone new. label Apr 28, 2026
@shobsi shobsi requested a review from Genesis929 April 29, 2026 06:33
@shobsi shobsi assigned Genesis929 and unassigned shobsi Apr 29, 2026
@Deeven-Seru Deeven-Seru force-pushed the fix-3033-bq-optional-parameters branch 3 times, most recently from d041565 to 88c3154 Compare May 4, 2026 04:37
@duwenxin99 duwenxin99 added the release candidate Use label to signal PR should be included in the next release. label May 6, 2026
Comment thread internal/tools/bigquery/bigquerysql/bigquerysql.go Outdated
Copy link
Copy Markdown
Contributor

@duwenxin99 duwenxin99 left a comment

Choose a reason for hiding this comment

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

Hi @Deeven-Seru, thanks for the PR! We hope to include this fix in the release tomorrow. Let me know if you have any issues fixing the test failures. Otherwise LGTM.

Comment thread internal/tools/bigquery/bigquerysql/bigquerysql_invoke_test.go Outdated
@Deeven-Seru Deeven-Seru force-pushed the fix-3033-bq-optional-parameters branch from 70ad9a2 to 02c44db Compare May 7, 2026 06:37
@Deeven-Seru
Copy link
Copy Markdown
Contributor Author

hi @duwenxin99 thanks for reviewing. done with final touches, please re initiate the checks

@Deeven-Seru Deeven-Seru force-pushed the fix-3033-bq-optional-parameters branch from 02c44db to 8919a5f Compare May 7, 2026 07:31
@duwenxin99
Copy link
Copy Markdown
Contributor

/gcbrun

@duwenxin99
Copy link
Copy Markdown
Contributor

/gcbrun

@duwenxin99 duwenxin99 enabled auto-merge (squash) May 7, 2026 15:59
@duwenxin99
Copy link
Copy Markdown
Contributor

/gcbrun

@duwenxin99 duwenxin99 merged commit 8e2b80a into googleapis:main May 7, 2026
14 checks passed
@Deeven-Seru
Copy link
Copy Markdown
Contributor Author

🎉

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

Labels

product: bigquery BigQuery release candidate Use label to signal PR should be included in the next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error processing GCP request: unable to execute query: bigquery: nil parameter

5 participants