Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Fix error when query job destination is None #3127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
na0fu3y wants to merge 1 commit into google:main
base: main
Choose a base branch
Loading
from na0fu3y:patch-1
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/google/adk/tools/bigquery/query_tool.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,14 @@ def execute_sql(
connection_properties=bq_connection_properties,
),
)
destination_dataset_id = None
if dry_run_query_job.destination:
destination_dataset_id = dry_run_query_job.destination.dataset_id

if (
dry_run_query_job.statement_type != "SELECT"
and dry_run_query_job.destination.dataset_id != bq_session_dataset_id
and destination_dataset_id != bq_session_dataset_id
and destination_dataset_id is not None
):
Comment on lines +197 to 205
Copy link

@gemini-code-assist gemini-code-assist bot Oct 9, 2025

Choose a reason for hiding this comment

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

medium

While the current implementation correctly fixes the bug, it can be simplified for better readability and conciseness. By leveraging Python's short-circuiting behavior with and, you can perform the check for dry_run_query_job.destination and access its dataset_id within the same conditional expression. This avoids creating a temporary variable and makes the logic more direct.

 if (
 dry_run_query_job.statement_type != "SELECT"
 and dry_run_query_job.destination
 and dry_run_query_job.destination.dataset_id != bq_session_dataset_id
 ):

return {
"status": "ERROR",
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /