fix: Fix error when query job destination is None

Merge https://github.com/google/adk-python/pull/3127

# What this PR does
This PR fixes a bug in the `execute_sql function` within `bigquery/query_tool.py`. The bug caused an error when executing queries that do not return a result set, such as a `CREATE TEMP FUNCTION` statement.

# The problem
Within `execute_sql,` when a user executed a query that doesn't produce a result set, like the following:

```sql
CREATE TEMP FUNCTION f() AS (0); SELECT f();
```

The corresponding BigQuery job object would have its `destination` property set to `None`. This caused an error because the code was written with the expectation of a valid destination table.

# The solution
The fix modifies `execute_sql` to check if the `query_job.destination` is None. If it is, the function correctly identifies the query as a statement that doesn't require a destination and allows it to complete successfully.

This ensures that `execute_sql` can robustly handle these types of queries.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3127 from na0fu3y:patch-1 69218a8d25699dfa2e18bb305087f01192e91e91
PiperOrigin-RevId: 829270885
This commit is contained in:
Naofumi Yamada
2025-11-06 22:27:35 -08:00
committed by Copybara-Service
parent a0cf97eba2
commit 0ccc43cf49
@@ -127,6 +127,7 @@ def _execute_sql(
)
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 {