BigQuery的脚本/过程刚刚在beta中发布-是否可以使用BigQuery python客户端来调用过程?
我尝试过:
query = """CALL `myproject.dataset.procedure`()...."""
job = client.query(query, location="US",)
print(job.results())
print(job.ddl_operation_performed)
print(job._properties) but that didn't give me the result set from the procedure. Is it possible to get the results?
谢谢!
如果过程中包含SELECT,则该过程有效:
create or replace procedure dataset.proc_output() BEGIN
SELECT t FROM UNNEST(['1','2','3']) t;
END;
代码:
from google.cloud import bigquery
client = bigquery.Client()
query = """CALL dataset.proc_output()"""
job = client.query(query, location="US")
for result in job.result():
print result
将输出:
Row((u'1',), {u't': 0})
Row((u'2',), {u't': 0})
Row((u'3',), {u't': 0})
但是,如果过程中有多个SELECT,则只能以这种方式获取最后一个结果集。