Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

feat: allow QueryJob.result() to be called on a dryRun query #1012

Description

@tswast

Attempting to call result() on a dryRun query results in the following exception.

    def test_dry_run(bigquery_client: bigquery.Client, query_api_method: str, scalars_table_multi_location: Tuple[str, str]):
        location, full_table_id = scalars_table_multi_location
        query_config = bigquery.QueryJobConfig()
        query_config.dry_run = True
    
        query_string = f"SELECT * FROM {full_table_id}"
        query_job = bigquery_client.query(query_string, location=location, job_config=query_config, api_method=query_api_method)
>       query_job.result()

tests/system/test_query.py:430: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
google/cloud/bigquery/job/query.py:1372: in result
    do_get_result()
../python-api-core/google/api_core/retry.py:283: in retry_wrapped_func
    return retry_target(
../python-api-core/google/api_core/retry.py:190: in retry_target
    return target()
google/cloud/bigquery/job/query.py:1362: in do_get_result
    super(QueryJob, self).result(retry=retry, timeout=timeout)
google/cloud/bigquery/job/base.py:713: in result
    return super(_AsyncJob, self).result(timeout=timeout, **kwargs)
../python-api-core/google/api_core/future/polling.py:137: in result
    raise self._exception
google/cloud/bigquery/job/query.py:1233: in _done_or_raise
    self._reload_query_results(retry=retry, timeout=transport_timeout)
google/cloud/bigquery/job/query.py:1214: in _reload_query_results
    self._query_results = self._client._get_query_results(
google/cloud/bigquery/client.py:1835: in _get_query_results
    resource = self._call_api(
google/cloud/bigquery/client.py:732: in _call_api
    return call()
../python-api-core/google/api_core/retry.py:283: in retry_wrapped_func
    return retry_target(
../python-api-core/google/api_core/retry.py:190: in retry_target
    return target()

...

E           google.api_core.exceptions.NotFound: 404 GET https://bigquery.googleapis.com/bigquery/v2/projects/swast-scratch/queries/None?maxResults=0&location=asia-northeast1&prettyPrint=false: Not found: Job swast-scratch:asia-northeast1.None
E           
E           (job ID: None)
E           
E                                            -----Query Job SQL Follows-----                                 
E           
E               |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |
E              1:SELECT * FROM swast-scratch.python_bigquery_tests_system_20211008194804_6e302d_tokyo.scalars
E               |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |    .    |

../python-cloud-core/google/cloud/_http.py:479: NotFound

This is because the QueryJob tries to fetch query results and/or job state, but there is no job ID in a dry run query response.

IMO, if we know something is a dryRun response, resullt() should do nothing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: bigqueryIssues related to the googleapis/python-bigquery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions