我正在尝试使用REST API创建一个Google BigQuery存储过程。我尝试了REST Resource routines的所有方法。然而,这并没有帮助。
有没有人通过REST API创建过BigQuery存储过程?如果是这样的话,是怎么做的?
发布于 2020-01-13 15:53:58
正如Graham在他的评论中所指出的,只需发出如下SQL查询:
CREATE PROCEDURE mydataset.AddDelta(INOUT x INT64, delta INT64)
BEGIN
SET x = x + delta;
END;与使用REST API的任何其他查询一样执行此操作。
发布于 2020-08-05 05:28:56
现在可以创建一个过程:
curl --request POST \
'https://bigquery.googleapis.com/bigquery/v2/projects/my-project/datasets/mydataset/routines?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"routineReference":{"projectId":"my-project","datasetId":"mydataset","routineId":"test_routine"},"routineType":"PROCEDURE","definitionBody":"BEGIN SET y = y + delta;END;","arguments":[{"name":"y","dataType":{"typeKind":"INT64"},"mode":"INOUT"},{"name":"delta","dataType":{"typeKind":"INT64"}}]}' \
--compressed一旦创建,你就可以调用它;
DECLARE accumulator INT64 DEFAULT 0;
CALL help.test_routine2(accumulator, 3);
CALL help.test_routine2(accumulator, 6);
SELECT accumulator;
Row accumulator
1 9您可以在我测试上述命令的位置执行Try the API。
https://stackoverflow.com/questions/59690214
复制相似问题