Skip to content

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

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

Closed
tswast opened this issue Oct 8, 2021 · 0 comments · Fixed by #1015
Closed

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

tswast opened this issue Oct 8, 2021 · 0 comments · Fixed by #1015
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tswast
Copy link
Contributor

tswast commented Oct 8, 2021

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.

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Oct 8, 2021
@tswast tswast added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant