Output parameter
General Description
Greenplum UDFs with output parameters are being transformed to Snowflake Stored Procedures, to maintain functional equivalence, due to Snowflake UDFs having some limitations executing DML (Data Manipulation Language) statements.
Since functions are being transformed into procedures, the transformation reference for PL/SQL also applies here.
Single out parameter
Greenplum
CREATE OR REPLACE FUNCTION functionSingleOutputParameter(OUT Message VARCHAR(100))
AS $$
BEGIN
Message := 'Assignment value. Thanks!';
END;
$$
LANGUAGE PLPGSQL;
SELECT procedureLabelSingle();
CREATE OR REPLACE FUNCTION functionSQLSingleOutputParameter(param int, out min_len int)
AS $$
SELECT min(col1)
FROM table1
WHERE col2 > param
$$
LANGUAGE SQL;
SELECT * FROM functionSQLSingleOutputParameter(0);procedurelabelsingle |
------------------------+
Assignment value. Thanks|
min_len |
-----------+
1 |Snowflake Scripting
Multiple out parameter
Greenplum
Snowflake Scripting
Known Issues
1. Out Parameters
Snowflake Scripting does not support OUT/INOUT parameters therefore these parameters are returned at the end of the procedure's body.
2. REFCURSOR Type not supported
In Snowflake, you can use stored procedures to execute SQL statements and return result sets, but the result sets are not returned as REFCURSOR objects. Instead, Snowflake supports returning result sets as tables, which can be queried and manipulated using SQL.
3. Missing name for the parameter
In Snowflake, all function parameters must have names, even if they also have data types.
4. Functions with parameterized queries are migrated to stored procedures in Snowflake
One of the main limitations of functions in Snowflake is that they do not allow the execution of parameterized queries within the function. That is why the use of stored procedures is made to emulate this functionality.
Related EWIs
MSC-GP0002: Non-returning Function translated to Stored Procedure.
MSC-GP0003: Non-returning Function translated to Stored Procedure.
MSCEWI1082: Auto-Generated code in order to support output parameters in Snowflake Scripting
MSCEWI1083: Output parameters are not supported but their functionality is being emulated
Last updated
Was this helpful?