python - 使用 BigQuery Client() 类时出现错误 TypeError: Object of type set is not JSON serializable
问题描述
当我尝试使用 Client() 运行 BigQuery 时,出现 JSON 不可序列化错误。这是我的代码片段:
client = Client()
query = { "select * from `abc`"}
query_job = client.query(query, location= US)
results = query_job.result().dataframe()
现在,当我尝试它时会抛出错误。请提供任何帮助。
解决方案
基于Bigquery python 示例,您需要传递query
值 asSTRING
并且传递的是 JSON 类型
例如:
from google.cloud import bigquery
client = bigquery.Client()
query = (
"SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` "
'WHERE state = "TX" '
"LIMIT 100"
)
query_job = client.query(
query,
location="US",
)
for row in query_job:
assert row[0] == row.name == row["name"]
希望能帮助到你。
推荐阅读
- php - 尝试在 bool 上读取属性“slug”
- javascript - Angular 11 测试与 Jest - rxjs 计时器的 Aync 错误
- colors - Povray:看似等效的颜色渐变中的颜色间距不同
- java - 如何打开和关闭文件中的每个链接(Selenium\Java)
- javascript - 如何检测 AdSense 是否在 JavaScript 中加载了广告?
- javascript - 函数上的最大调用堆栈超出错误查找小公倍数
- twig - 电子市场主题激活时的树枝问题
- python - 添加选项但未显示在选择框中
- php - react js组件和laravel刀片可以在一个项目中工作吗?如果没有,最好的方法是什么?
- delphi - 字符串助手的拆分函数不考虑最后一个分隔符后的空格