我需要使用数组来运行参数化查询。
BigQuery API的Python客户端库
id_pull = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
query = "SELECT column1 FROM `table1` WHERE id = @get_id;"
query_params = [
bigquery.ArrayQueryParameter(
'get_id', 'INT64', id_pull)
]
job_config = bigquery.QueryJobConfig()
job_config.query_parameters = query_params
query_job = client.query(query, location='US', job_config=job_config) #API request-starts query
results = query_job.result() # Waits for job to complete.
我遵循了文档中的说明,但是,执行后出现此错误:
提高self._exception google.api_core.exceptions.BadRequest:400否 参数类型:INT64, 阵列。支持的签名:ANY = ANY [1:67]
有人是什么问题以及如何解决?
答案 0 :(得分:1)
我认为问题出在您的WHERE子句
代替
WHERE id = @get_id
应该类似于
WHERE id IN UNNEST(@get_id)