Skip to content

GBQ query getting error of '>' not supported between instances of 'int' and 'object' randomly #1612

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
moveingsun opened this issue Jul 17, 2023 · 9 comments · Fixed by #1645
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@moveingsun
Copy link

moveingsun commented Jul 17, 2023

hi folks, we have a service that run hundreds of thousands GBQ query each day using python client. And recently I've notice the GBQ client fail randomly with error msg "'>' not supported between instances of 'int' and 'object' randomly", which seems to be an issue on client code. And the error just appear randonly. I've opened a support ticket in GCP console, but the conversation there get us nothing and i have to report the issue here, can anyone help me to understand what could cause this issue and how to get it fixed?

Environment details

  • OS type and version: Rocky Linux 8
  • Python version: 3.9.15
  • pip version: 22.2
  • google-cloud-bigquery version: 3.10.0 and above

Steps to reproduce

Unable to reproduce, happen randomly in our code.

Code example

try:
    job = self.gbq_client.query(cmd, job_config=job_config, job_id=self.job_id, timeout=30)
    self.session_id = job._properties["jobReference"].get("jobId", self.session_id)
    self._result = job
    job.result()
    failure = job.exception()
    if failure:
        raise QueryExecutionError(failure)
except BadRequest as e:
    raise QueryExecutionError(str(e))
except Exception as e:
    raise e

Stack trace

 File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/db_core/drivers/gbq_driver.py", line 317, in _execute
    failure = job.exception()
  File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/google/api_core/future/polling.py", line 282, in exception
    self._blocking_poll(timeout=timeout)
  File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/google/cloud/bigquery/job/query.py", line 1257, in _blocking_poll
    super(QueryJob, self)._blocking_poll(timeout=timeout, **kwargs)
  File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/google/api_core/future/polling.py", line 137, in _blocking_poll
    polling(self._done_or_raise)(retry=retry)
  File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/google/api_core/retry.py", line 349, in retry_wrapped_func
    return retry_target(
  File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/google/api_core/retry.py", line 191, in retry_target
    return target()
  File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/google/cloud/bigquery/job/query.py", line 1379, in _done_or_raise
    self._reload_query_results(retry=retry, timeout=transport_timeout)
  File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/google/cloud/bigquery/job/query.py", line 1360, in _reload_query_results
    self._query_results = self._client._get_query_results(
  File "/pyenv/versions/worker-k8s/lib/python3.9/site-packages/google/cloud/bigquery/client.py", line 1895, in _get_query_results
    timeout = max(timeout, _MIN_GET_QUERY_RESULTS_TIMEOUT)
TypeError: '>' not supported between instances of 'int' and 'object'

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Jul 17, 2023
@tswast
Copy link
Contributor

tswast commented Jul 17, 2023

Thanks for the report. This appears to be a duplicate of this issue: #1459 due to a breaking change introduced in google-api-core package.

This should have been fixed in version 3.10 and later of this package, though.

@moveingsun
Copy link
Author

actually with version google-cloud-bigquery==3.11.3 and google-api-core-2.11.1. the issue happens more freqnently. for reference, with google-cloud-bigquery==3.11.3 and google-api-core-2.11.1, it happen around 240 times a day, with google-cloud-bigquery==3.10 and google-api-core-2.11.1, our log showed it only happen 2 times a day. we have to downgrade the version to 3.10 to reduce the issue frequency. so it seems a different issue?

@moveingsun
Copy link
Author

@tswast can you provide some update?

@phongphung
Copy link

for me,
calling job.execution() for job.result() before query completed will cause the error,
work around with checking query_job.running() to wait until job finish then continue work for now

@tswast
Copy link
Contributor

tswast commented Aug 4, 2023

Thanks for checking in with the versions. It sounds like there is some part of the breaking change in google-api-core that hasn't fully been fixed in google-cloud-bigquery.

CC @chalmerlowe

@tswast tswast added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Aug 4, 2023
@shollyman
Copy link
Contributor

Yeah, looks like this is another callsite where the new default object representation isn't handled. Another change similar to #1541 is needed for

if timeout is not None:
timeout = max(timeout, _MIN_GET_QUERY_RESULTS_TIMEOUT)

@meredithslota
Copy link
Contributor

Googlers, the internal support issue is b/290415719 for additional context. @moveingsun I'm sorry you didn't see a resolution through support, it would have been faster if they had routed us your ticket internally, but that's neither here nor there now (we'll suggest some process changes internally, ha).

shollyman added a commit to shollyman/python-bigquery that referenced this issue Aug 16, 2023
Changes to python-api-core can in certain cases cause timeout to be
represented as a literal python base object type.  This CL adjusts
logic that selects from multiple timeout values to better handle this
case, which previously assumed either a None or scalar value being
present.

Fixes: googleapis#1612
chalmerlowe pushed a commit that referenced this issue Aug 21, 2023
* fix: relax timeout expectations

Changes to python-api-core can in certain cases cause timeout to be
represented as a literal python base object type.  This CL adjusts
logic that selects from multiple timeout values to better handle this
case, which previously assumed either a None or scalar value being
present.

Fixes: #1612

* augment testing

* blacken and lint fixes

* unused import
@cmarkle85
Copy link

As a user, I'm experiencing this issue and I'm not sure what the fix / workaround is. Please advise.

@chalmerlowe
Copy link
Collaborator

chalmerlowe commented Apr 4, 2024

A question came in to me, but is not reflected here (likely cause it is closed). To answer that question: this should be fixed in version 3.12.0+, which was released in October 2023.

See changelog

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. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
7 participants