【发布时间】:2020-02-18 00:07:41
【问题描述】:
BigQuery 的脚本/程序刚刚推出测试版 - 是否可以使用 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?
谢谢!
已编辑 - 我正在调用的存储过程
CREATE OR REPLACE PROCEDURE `Project.Dataset.Table`(IN country STRING, IN accessDate DATE, IN accessId, OUT saleExists INT64)
BEGIN
IF EXISTS (SELECT 1 FROM dataset.table where purchaseCountry = country and purchaseDate=accessDate and customerId = accessId)
THEN
SET saleExists = (SELECT 1);
ELSE
INSERT Dataset.MissingSalesTable (purchaseCountry, purchaseDate, customerId) VALUES (country, accessDate, accessId);
SET saleExists = (SELECT 0);
END IF;
END;
【问题讨论】:
-
您要捕获哪个语句的输出?
SELECT 1 FROM dataset.table where purchaseCountry = country and purchaseDate=accessDate and customerId = accessId?为什么当前程序对您不起作用? -
或者只是 saleExists 1/0,这与 SELECT 1 FROM dataset.table 本质上是一样的
-
更新了我的答案,这也简化了您的程序主体。
标签: google-bigquery google-api-python-client