Skip to content

Update outdated BigQuery integration sample code - #2214

Merged
joefernandez merged 2 commits into
google:mainfrom
wukath:fix-bigquery-docs-outdated-sample
Sep 10, 2026
Merged

Update outdated BigQuery integration sample code#2214
joefernandez merged 2 commits into
google:mainfrom
wukath:fix-bigquery-docs-outdated-sample

Conversation

@wukath

@wukath wukath commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Fixes the outdated sample code on the BigQuery integration page, reported in an ADK friction log.

Related task: b/559149787

Deprecated import path

All five auth snippets and the included sample imported from google.adk.tools.bigquery. That module is now a back-compat shim that emits a DeprecationWarning telling you to use google.adk.integrations.bigquery:

DeprecationWarning: google.adk.tools.bigquery is deprecated, use google.adk.integrations.bigquery instead

Updated to the new path throughout, including google.adk.integrations.bigquery.config for BigQueryToolConfig / WriteMode. This matches what the BigQuery sample agent in adk-python already does.

asyncio.run() on create_session()

The sample wrapped the session setup in asyncio.run(session_service.create_session(...)). That fails with RuntimeError: asyncio.run() cannot be called from a running event loop in Colab and other notebooks, which is where most people first paste this.

Restructured around an async main() that awaits create_session() and iterates runner.run_async(), with a note about calling await main() directly in a notebook. This is the same shape the other snippets in examples/python/snippets/tools/built-in-tools/ already use (e.g. google_search.py).

Not changed: the model string

The friction log also wondered whether Agent(model=...) needs a google.adk.models.Gemini object instead of a "gemini-2.5-flash" style string. It doesn't — LLMRegistry.resolve("gemini-2.0-flash") still returns google.adk.models.google_llm.Gemini, so the string form remains supported. Left as-is.

Verification

  • New imports resolve with no DeprecationWarning (checked against ADK 2.6.3).
  • BigQueryToolConfig(write_mode=WriteMode.BLOCKED) constructs from the new path.
  • The rewritten async setup was smoke-tested: create_session() awaits cleanly, the session is resolvable through the runner, and run_async() is present.

The BigQuery integration page still imports from google.adk.tools.bigquery,
which now raises a DeprecationWarning pointing at
google.adk.integrations.bigquery. Update all five auth snippets and the
included sample to the new path.

The sample also wrapped session_service.create_session() in asyncio.run(),
which blows up in Colab and other notebooks where a loop is already running.
Restructure it around an async main() that awaits create_session() and
iterates runner.run_async(), matching the pattern the other built-in tool
snippets already use.

Bug: b/559149787
@netlify

netlify Bot commented Sep 9, 2026

Copy link
Copy Markdown

Deploy Preview for adk-docs-preview ready!

Name Link
🔨 Latest commit 34cd547
🔍 Latest deploy log https://app.netlify.com/projects/adk-docs-preview/deploys/6aa2cf9ddc9ba60008392e3f
😎 Deploy Preview https://deploy-preview-2214--adk-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@joefernandez joefernandez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the update!

@joefernandez
joefernandez enabled auto-merge (squash) September 10, 2026 15:41
@joefernandez
joefernandez merged commit fb23822 into google:main Sep 10, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants