我有一个函数可以从对BigQuery的查询中检索熊猫的数据,这个查询在过去几个月里运行得很好。今天,在没有任何更改的情况下,它在引发此异常的GoogleColab记事本中停止工作:
从ArrowIOError读取时发生了BigQuery类型的异常。参数:(“无法从BufferReader读取负数字节”)
我的代码:
def read_from_bigquery_client(bq_client, project_id, sql, curr_func):
try:
df = bq_client.query(sql, project=project_id).to_dataframe()
return df
except Exception as ex:
template = "An exception of type {0} occurred reading from BigQuery. Arguments:\n{1!r}\nFunction: {2}"
message = template.format(type(ex).__name__, ex.args, curr_func)
print(message)
return None
客户Auth:
credentials = service_account.Credentials.from_service_account_file(local_cred_filename)
bq_client = bigquery.Client(credentials=credentials,
project=credentials.project_id)
当直接应用于BigQuery时,我尝试过的查询工作得很好,另外,正如前面提到的那样,这些查询也能正常工作。
谢谢你的帮助。
发布于 2020-07-23 01:59:40
发布于 2020-09-28 02:36:16
我将google-cloud-bigquery
的版本降到了1.24.0,但错误仍然是完整的。其他版本有:
pyarrow==0.11.1
pandas==0.23.4
pandas-gbq==0.7.0
google-cloud-bigquery==1.24.0
发布于 2021-06-28 08:03:52
我也面临着同样的问题,直到我升级了我的熊猫包,显然我从文档中看到,超过0.29.0的熊猫版本可以很好地使用google-cloud-bigquery
更新大熊猫的最佳方法是:
pip3 install --upgrade pandas
https://stackoverflow.com/questions/63031898
复制相似问题