python - bigquery python中的流式插入
问题描述
python SDK的Client.insert_rows
记录为
通过流 API 将行插入表中。
请参阅 https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll
但是当我尝试将它与需要流式传输的大数据一起使用时,我收到了这个错误:
Traceback (most recent call last):
File "demo.py", line 15, in <module>
exit(main())
File "demo.py", line 12, in main
client.insert_rows(table, rows)
File "google/cloud/bigquery/bigquery_future/client.py", line 1213, in insert_rows
return self.insert_rows_json(table, json_rows, **kwargs)
File "google/cloud/bigquery/bigquery_future/client.py", line 1293, in insert_rows_json
data=data)
File "google/cloud/bigquery/bigquery_future/client.py", line 301, in _call_api
return call()
File "google/api_core/retry.py", line 246, in retry_wrapped_func
on_error=on_error,
File "google/api_core/retry.py", line 163, in retry_target
return target()
File "google/cloud/core_future/_http.py", line 279, in api_request
raise exceptions.from_http_response(response)
google.api_core.exceptions.BadRequest: 400 POST https://www.googleapis.com/bigquer
y/v2/projects/myproject/datasets/mydataset/tables/mytable/insertAll:
Request payload size exceeds the limit: 10915700 bytes.
深入研究代码,它肯定会在向文档中提到的 REST API 发送 POST http 请求之前对数据进行两次传递(我已经小心地从生成器中产生了这些数据)。该 API 将单个 JSON 对象指定为主体,这不是可流式传输的格式,而且我根本看不到该端点中的流式传输有任何允许。
我错过了什么?SDK 开发人员对流的定义是否与我的完全不同?流式 API 的大小限制如何?
解决方案
推荐阅读
- r - R 中 revoScaleR::rxGlm() 的方差分析问题
- poppler - 如何在 poppler 中配置字体替换
- date - PowerBI、DAX。有没有办法为切片器设置上限?
- ruby - 用初始化理解 Ruby define_method
- reactjs - 如何迭代元素并根据特定条件更新 React Js 中的对象的条目
- mongodb - golang mongodb 构建引用关系
- reactjs - React Context API 和 Apollo 缓存内存之间的区别
- django - 如何更改在普通 django 中工作的此功能以使其与序列化程序一起使用?
- java - org.hibernate.exception.GenericJDBCException:无法执行结果的顺序读取(转发)
- reactjs - 如何正确测试我的 App 组件以验证路由是否呈现正确的组件