SnowDDL
Search…
PROCEDURE
Config path: /<database>/<schema>/procedure/<name>(<dtypes>).yaml
Example:
arguments:
ticket_no: VARCHAR(13)
flight_id: NUMBER(10,0)
boarding_no: NUMBER(10,0)
seat_no: VARCHAR(4)
​
returns: BOOLEAN
​
body: |-
BEGIN
INSERT INTO boarding_passes (ticket_no, flight_id, boarding_no, seat_no)
VALUES (:TICKET_NO, :FLIGHT_ID, :BOARDING_NO, :SEAT_NO);
​
RETURN TRUE;
END;

Schema

  • language (str) - language of function (default: SQL)
  • arguments (dict)
    • {key} (ident) - argument name
    • {value} (str) - argument data type
  • returns (str) - for single return value, return data type --- OR ---
  • returns (dict) - for table return values
    • {key} (ident) - return column name
    • {value} (str) - return column data type
  • body (str) - procedure body
  • is_strict (bool) - is procedure STRICT (always returns NULL on NULL input)
  • is_execute_as_caller (bool) - is function executed "as caller" (default "as owner")
  • imports (list) - files to import (usually JAR packages)
    • {items} (dict)
      • stage (ident) - name of stage
      • path (str) - path to file
  • packages (list) - Snowflake system packages to import as dependencies
    • {items} (str) - name of package, with optional version of package
  • handler (str) - name of class and method to be called
  • comment (str)

Usage notes

  1. 1.
    Snowflake supports overloading of procedure names. Multiple procedures may have the same name as long as they have different arguments. It is required to use comma-separated base data types of arguments in config names. For example: my_procedure(number).yaml, my_procedure(varchar,number).yaml
  2. 2.
    Make sure to read & fully understand "caller rights" and "owners rights" for stored procedures. It is very important for security.
  3. 3.
    Files for imports should be maintained using STAGE FILES.
  4. 4.
    If function body is empty, handler and imports with pre-compiled JAR or Python code are required.
  5. 5.
    runtime_version should be specified as string with explicit double-quotes (e.g. "3.8"). Otherwise YAML parser may confuse it with number, which may cause some unwanted effects.

Links

​
Copy link
On this page
Schema
Usage notes
Links