'Dynamic Procedure BigQuery

Does Bigquery support dynamic procedure calls? I am looking to generate a procedure name as string based on variables and call the string.

EXECUTE IMMEDIATE returns this error clearly it doesn't support CALL. Is there any other way? SQL created by EXECUTE IMMEDIATE contains unsupported statement type: CallStatement.

Thank you.



Solution 1:[1]

I make this answer for visibility, the approach you can use is as follow (as mention in the comments by mikhail):

CREATE OR REPLACE PROCEDURE `project-id.dataset`.maker(option INT64)
BEGIN
IF option=1  THEN
    CALL `project-id.dataset`.create_user(); #call to procedure
  ELSEIF option=2 THEN
    CALL `project-id.dataset`.create_customer(); #call to procedure
ELSE 
  SELECT "END"; #default
END IF;
END

to use

CALL `project-id.dataset`.maker(2)

As stated in the comments, execute immediate do not support at the moment the usage of call. I also found a feature request about supporting using call with execute immediate on google issue tracker you can leave a comment to support the feature request.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Betjens