BigQuery StoreProcedure returns a result-set(存储过程返回结果集)
StoreProcedure A 调用 StoreProcedure B(A -> B),B返回一个结果集给A使用:
定义 StoreProcedure B :
CREATE OR REPLACE PROCEDURE `11864627-hsirnd-dev.POC_HK_DIPD_APP.TEST_SP`(pIndex STRING, OUT ResultSet ARRAY<STRUCT<indexAbbr STRING, RIC STRING, TradingDate DATE, TradingCurr STRING, Weight NUMERIC>>) BEGIN DECLARE RES DEFAULT ARRAY(SELECT STRUCT(indexAbbr, RIC, TradingDate, TradingCurr, RecappedWeight) FROM `hsbc-11864627-hsirnd-dev.POC_HK_DIPD_IDM_DB01.idxBacktestDailyWeight` WHERE indexAbbr = pIndex); SET ResultSet = RES; END;
调用 StoreProcedure B :
BEGIN DECLARE RES ARRAY<STRUCT<indexAbbr STRING, RIC STRING, TradingDate DATE, TradingCurr STRING, Weight NUMERIC>>; CALL `11864627-hsirnd-dev.POC_HK_DIPD_APP.TEST_SP`('H40-2', RES); SELECT * FROM UNNEST(RES); END;