Skip to content

feat(bigquery): add bigquery_create_procedure sample to create a SQL … - #14753

Merged
iennae merged 2 commits into
mainfrom
feat/bq-create-procedure
Nov 17, 2026
Merged

iennae merged 2 commits into
mainfrom
feat/bq-create-procedure

Conversation

@iennae

@iennae iennae commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

…stored procedure

Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/procedures) needs a standalone, tested Python code sample demonstrating how to create a SQL stored procedure (region tag bigquery_create_procedure).

Solution:

  • Add create_procedure(project_id: str, dataset_id: str) -> None in bigquery/stored_procedures/bigquery_create_procedure.py (Create a reusable multi-statement GoogleSQL stored procedure inside a BigQuery dataset using CREATE PROCEDURE.)
  • Add unit tests (bigquery/stored_procedures/bigquery_create_procedure_test.py) covering both the success path and API error handling (GoogleAPICallError)

Description

Fixes #

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

@iennae
iennae requested review from a team and chalmerlowe as code owners November 2, 2026 23:31
@snippet-bot

snippet-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples. labels Nov 2, 2026

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

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.

Code Review

This pull request introduces a new sample for creating a BigQuery stored procedure, complete with its implementation, unit tests, and configuration files. The feedback suggests updating the Python test configuration in noxfile_config.py to target only the oldest and newest supported Python versions (3.10 and 3.13) by ignoring intermediate versions. Additionally, it recommends removing the unnecessary environment marker for Python 3.10 in requirements-test.txt and using the === operator for strict version pinning.

@iennae
iennae force-pushed the feat/bq-create-procedure branch 3 times, most recently from c445f53 to 159a10b Compare November 3, 2026 23:32

@amcolin amcolin left a comment

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.

LGTM!

…stored procedure

Problem:
The BigQuery documentation (https://cloud.google.com/bigquery/docs/procedures)
needs a standalone, tested Python code sample demonstrating how to
create a SQL stored procedure (region tag `bigquery_create_procedure`).

Solution:
- Add `create_procedure(project_id: str, dataset_id: str) -> None` in `bigquery/stored_procedures/bigquery_create_procedure.py`
  (Create a reusable multi-statement GoogleSQL stored procedure inside a BigQuery dataset using CREATE OR REPLACE PROCEDURE.)
- Add unit tests (`bigquery/stored_procedures/bigquery_create_procedure_test.py`) covering both the success
  path and API error handling (`GoogleAPICallError`)
@iennae
iennae force-pushed the feat/bq-create-procedure branch from 159a10b to 3f431d1 Compare November 17, 2026 04:57
…re tests

Problem:
The tests replaced the client class with `lambda project=None: mock_client`.
A lambda only accepts that one keyword, so the test would break for reasons
unrelated to the sample if the constructor call changed, and it records
nothing, so the tests could not verify how the client was created.

Solution:
Patch the client class with `mock.MagicMock(return_value=mock_client)` and
assert in the success test that the sample constructed it exactly once with
the expected arguments.
@iennae
iennae merged commit c83528b into main Nov 17, 2026
14 of 19 checks passed
@iennae
iennae deleted the feat/bq-create-procedure branch November 17, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the BigQuery API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants