Commit 0ccc43c
fix: Fix error when query job destination is None
Merge #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=#3127 from na0fu3y:patch-1 69218a8
PiperOrigin-RevId: 8292708851 parent a0cf97e commit 0ccc43c
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
0 commit comments