SnowConvert: Postgres Issues¶
SSC-EWI-PG0003¶
Severity¶
Low
Description¶
Inheritance between tables is allowed in PostgreSQL, but Snowflake does not support it. For more information about inheritance in PostgreSQL click here.
Code Example¶
Input Code:¶
ALTER TABLE Table1
ADD CONSTRAINT const3 UNIQUE (zip);
Output Code:¶
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0003 - TABLE INHERITANCE IS NOT SUPPORTED IN SNOWFLAKE. ***/!!!
ALTER TABLE Table1
ADD CONSTRAINT const3 UNIQUE (zip);
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0013¶
Severity¶
Medium
Description¶
This error is added when the Raise exception is transformed to a user-defined stored procedure.
Also be aware that Raise Exception outside an Exception Block is not supported because it requires creating a custom exception based on dynamic data, which is not supported by Snowflake. Snowflake only supports the creation of new exceptions with a literal message.
Code Example¶
Input Code:¶
CREATE FUNCTION FunctionName1() RETURNS void
AS
$$
DECLARE
v_var1 character varying(50);
v_var2 character varying(50);
BEGIN
v_var1 := 'exception1';
v_var2 := 'exception2';
RAISE EXCEPTION 'Exception %',v_var1;
EXCEPTION
WHEN OTHERS THEN
RAISE EXCEPTION '%',v_var2;
RETURN;
END;
$$
LANGUAGE plpgsql NO SQL;
Output Code:¶
!!!RESOLVE EWI!!! /*** SSC-EWI-GP0002 - NON-RETURNING FUNCTION TRANSLATED TO STORED PROCEDURE ***/!!!
CREATE OR REPLACE PROCEDURE FunctionName1 () RETURNS STRING
LANGUAGE SQL
AS
$$
DECLARE
v_var1 character varying(50);
v_var2 character varying(50);
BEGIN
v_var1 := 'exception1';
v_var2 := 'exception2';
LET SC_RAISE_MESSAGE VARCHAR;
SC_RAISE_MESSAGE := STRING_FORMAT_UDF('Exception %', array_construct(:v_var1));
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0013 - RAISE EXCEPTION TRANSLATED TO USER-DEFINED STORED PROCEDURE CALL. ***/!!!
CALL RAISE_MESSAGE_UDF('EXCEPTION', :SC_RAISE_MESSAGE);
RETURN 'SUCCESS';
EXCEPTION
WHEN OTHER THEN
SC_RAISE_MESSAGE := STRING_FORMAT_UDF('%', array_construct(:v_var2));
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0013 - RAISE EXCEPTION TRANSLATED TO USER-DEFINED STORED PROCEDURE CALL. ***/!!!
CALL RAISE_MESSAGE_UDF('EXCEPTION', :SC_RAISE_MESSAGE);
RAISE;
RETURN;
END;
$$;
These are the UDFs used in the transformation:
CREATE OR REPLACE FUNCTION STRING_FORMAT_UDF(PATTERN VARCHAR, ARGS VARIANT)
RETURNS VARCHAR
LANGUAGE JAVASCRIPT
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "udf", "convertedOn": "09/09/2024" }}'
AS
$$
var placeholder_str = "{%}";
var result = PATTERN.replace(/(?<!%)%(?!%)/g, placeholder_str).replace("%%","%");
for (var i = 0; i < ARGS.length; i++)
{
result = result.replace(placeholder_str, ARGS[i]);
}
return result;
$$;
CREATE OR REPLACE PROCEDURE RAISE_MESSAGE_UDF(LEVEL VARCHAR, MESSAGE VARCHAR)
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "udf", "convertedOn": "09/09/2024" }}'
AS
$$
BEGIN
RETURN 'Logged message: ' || LEVEL || ' - ' || MESSAGE;
END;
$$;
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0006¶
Severity¶
Medium
Description¶
This error is added when a FOR loop’s body references a variable using the label. Snowflake does not support referencing a variable using the qualified name.
Code Example¶
Input Code:¶
CREATE OR REPLACE PROCEDURE procedure1(out result VARCHAR(100))
LANGUAGE plpgsql
AS $$
BEGIN
result := '<';
<<outer_loop>>
for i in 1..3 loop
<<inner_loop>>
for i in 4..6 loop
result := result || '(' || outer_loop.i || ', ' || i || ')';
end loop inner_loop;
end loop outer_loop;
result := result || '>';
END;
$$;
Output Code:¶
CREATE OR REPLACE PROCEDURE procedure1 (result VARCHAR(100))
RETURNS VARIANT
LANGUAGE SQL
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "redshift", "convertedOn": "02/16/2025", "domain": "test" }}'
AS $$
BEGIN
result := '<';
for i in 1 TO 3 loop
for i in 4 TO 6 loop
result := result || '(' ||
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0006 - REFERENCE TO A VARIABLE USING THE LABEL IS NOT SUPPORTED BY SNOWFLAKE. ***/!!! outer_loop.i || ', ' || i || ')';
end loop inner_loop;
end loop outer_loop;
result := result || '>';
RETURN OBJECT_CONSTRUCT('result', :result);
END;
$$;
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0002¶
Severity¶
Low
Description¶
The use of the following index parameters in constraints are not supported by Snowflake.
INCLUDE
WITH
USING INDEX TABLESPACE
Code Example¶
Input Code:¶
CREATE TABLE Table1 (
code char(5),
date_prod date,
CONSTRAINT production UNIQUE(date_prod) INCLUDE(code)
);
CREATE TABLE Table2 (
name varchar(40),
UNIQUE(name) WITH (fillfactor=70)
);
CREATE TABLE Table3 (
name varchar(40),
PRIMARY KEY(name) USING INDEX TABLESPACE tablespace_name
);
Output Code:¶
CREATE TABLE Table1 (
code char(5),
date_prod date,
CONSTRAINT production UNIQUE(date_prod)
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0002 - INCLUDE PARAMETER NOT APPLICABLE. CONSTRAINT INDEX PARAMETERS ARE NOT SUPPORTED IN SNOWFLAKE. ***/!!! INCLUDE(code)
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "postgresql", "convertedOn": "09/17/2024" }}';
CREATE TABLE Table2 (
name varchar(40),
UNIQUE(name)
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0002 - WITH PARAMETER NOT APPLICABLE. CONSTRAINT INDEX PARAMETERS ARE NOT SUPPORTED IN SNOWFLAKE. ***/!!! WITH (fillfactor=70)
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "postgresql", "convertedOn": "09/17/2024" }}';
CREATE TABLE Table3 (
name varchar(40),
PRIMARY KEY(name)
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0002 - USING PARAMETER NOT APPLICABLE. CONSTRAINT INDEX PARAMETERS ARE NOT SUPPORTED IN SNOWFLAKE. ***/!!! USING INDEX TABLESPACE tablespace_name
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "postgresql", "convertedOn": "09/17/2024" }}';
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0012¶
Description¶
The NOT VALID
constraint option is used in the context of adding or altering a constraint to indicate that the constraint should be added or modified without checking the existing data for compliance with the constraint. This clause is not supported by Snowflake.
Code Example¶
Input Code:¶
ALTER TABLE Table1 *
ADD CONSTRAINT const UNIQUE (zip) NOT VALID;
Output Code:¶
ALTER TABLE Table1
ADD CONSTRAINT const UNIQUE (zip)
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0012 - NOT VALID CONSTRAINT OPTION IS NOT SUPPORTED BY SNOWFLAKE. ***/!!! NOT VALID;
Recommendations¶
No additional user actions are required.
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0009¶
Severity¶
Low
Description¶
In the original code, there are various objects that can receive comments. However, in Snowflake, several of these objects do not exist, and thus, comments cannot be assigned to them. The code for handling these scenarios is commented out to prevent any potential errors.
Code Example¶
Input Code:¶
COMMENT ON RULE rule_name on TABLE_NAME IS 'this is a comment';
Output Code:¶
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0009 - COMMENT ON 'RULE' IS NOT SUPPORTED BY SNOWFLAKE. ***/!!!
COMMENT ON RULE rule_name on TABLE_NAME IS 'this is a comment';
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0008¶
Severity¶
High
Description¶
The use of interval
within the to_char
to convert date/times data types into text is not supported in Snowflake.
Code Example¶
Input Code:¶
SELECT to_char(interval '15h 2m 12s', 'HH24:MI:SS');
Output Code:¶
SELECT to_char(INTERVAL '15h, 2m, 12s', 'HH24:MI:SS') !!!RESOLVE EWI!!! /*** SSC-EWI-PG0008 - THE USE OF INTERVAL WITHIN TO_CHAR IS NOT SUPPORTED BY SNOWFLAKE. ***/!!!;
For more information please refer to
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0005¶
Severity¶
Medium
Description¶
This error is added because Snowflake does not support date/numeric formats in some functions as is supported in the source language.
The following format elements are the ones that may behave differently in Snowflake:
Date / Time¶
Format Element | Description |
---|---|
HH | Hour of day (01–12). |
MS | Millisecond (000–999). |
US | Microsecond (000000–999999). |
SSSS, SSSSS | Seconds past midnight (0–86399). |
Y,YYY | Year (4 or more digits) with comma. |
YYY | Last 3 digits of year. |
Y | Last digit of year. |
IYYY | ISO 8601 week-numbering year(4 or more digits). |
IYY | Last 3 digits of ISO 8601 week-numbering year. |
IY | Last 2 digits of ISO 8601 week-numbering year. |
I | Last digit of ISO 8601 week-numbering year. |
BC, bc, AD or ad | Era indicator (without periods). |
B.C., b.c., A.D. or a.d. | Era indicator (with periods). |
MONTH | Full upper case month name (blank-padded to 9 chars). |
Month | Full capitalized month name (blank-padded to 9 chars). |
month | Full lower case month name (blank-padded to 9 chars). |
DAY | Full upper case day name (blank-padded to 9 chars). |
Day | Full capitalized day name (blank-padded to 9 chars). |
day | Full lower case day name (blank-padded to 9 chars). |
DDD | Day of year (001–366). |
IDDD | Day of ISO 8601 week-numbering year (001–371; day 1 of the year is Monday of the first ISO week). |
D | Day of the week, Sunday (1) to Saturday (7). |
ID | ISO 8601 day of the week, Monday (1) to Sunday (7). |
W | Week of month (1–5) (the first week starts on the first day of the month). |
WW | Week number of year (1–53) (the first week starts on the first day of the year). |
IW | Week number of ISO 8601 week-numbering year (01–53; the first Thursday of the year is in week 1). |
CC | Century (2 digits) (the twenty-first century starts on 2001-01-01). |
J | Julian Date. |
Q | Quarter. |
RM | Month in upper case Roman numerals (I–XII; I=January). |
rm | Month in lower case Roman numerals (i–xii; i=January). |
TZ | Upper case time-zone abbreviation (only supported in to_char ). |
tz | Lower case time-zone abbreviation (only supported in to_char ). |
TZH | Time-zone hours. |
TZM | Time-zone minutes. |
OF | Time-zone offset from UTC (only supported in to_char ). |
FM prefix | Fill mode (suppress leading zeroes and padding blanks). |
TH suffix | Upper case ordinal number suffix. |
th suffix | Lower case ordinal number suffix. |
FX prefix | Fixed format global option (see usage notes). |
TM prefix | Translation mode (use localized day and month names based on lc_time). |
SP suffix | Spell mode. |
For more information please refer to PostgreSQL Date/Time formats.
The transformation of the TO_CHAR function supports most of this format elements, for a full list of suppported format elements and their equivalent mappings please refer to the Translation specification
Numeric ¶
Pattern |
Description |
---|---|
PR |
negative value in angle brackets |
RN |
Roman numeral (input between 1 and 3999) |
TH or th |
ordinal number suffix |
V |
shift specified number of digits (see notes) |
EEEE |
exponent for scientific notation |
For more information please refer to PostgreSQL Numeric formats.
Code Example¶
Input Code:¶
SELECT
DATE_TRUNC('decade', TIMESTAMP '2017-03-17 02:09:30'),
DATE_TRUNC('century', TIMESTAMP '2017-03-17 02:09:30'),
DATE_TRUNC('millennium', TIMESTAMP '2017-03-17 02:09:30');
Output Code:¶
SELECT
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0005 - DECADE FORMAT IS NOT SUPPORTED IN SNOWFLAKE. ***/!!!
DATE_TRUNC('decade', TIMESTAMP '2017-03-17 02:09:30'),
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0005 - CENTURY FORMAT IS NOT SUPPORTED IN SNOWFLAKE. ***/!!!
DATE_TRUNC('century', TIMESTAMP '2017-03-17 02:09:30'),
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0005 - MILLENNIUM FORMAT IS NOT SUPPORTED IN SNOWFLAKE. ***/!!!
DATE_TRUNC('millennium', TIMESTAMP '2017-03-17 02:09:30');
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0015¶
Severity¶
Medium
Description¶
In PostgreSQL, it is possible to use a FETCH statement without INTO to print on the console the values of fetched rows. However, Snowflake requires the FETCH statement to specify the INTO clause with the variables where the fetched row values are going to be stored.
Whenever a FETCH with no INTO is found in the code, SnowConvert will generate this EWI to notify the user that this type of FETCH is not supported.
Code Example¶
Input Code:¶
FETCH PRIOR FROM cursor1;
Output Code:¶
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0015 - FETCH CURSOR WITHOUT TARGET VARIABLES IS NOT SUPPORTED IN SNOWFLAKE ***/!!!
FETCH PRIOR FROM cursor1;
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0001¶
Severity¶
Medium
Description¶
This error is added because SnowConvert does not support the age()
functionality.
Code Example¶
Input Code:¶
SELECT
age(date1::date, date2::date)
FROM
Table1;
Output Code:¶
SELECT
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0001 - AGE IS NOT SUPPORTED ON SNOWFLAKE. ***/!!!
age(date1::date, date2::date)
FROM
Table1;
Recommendations¶
The
Datediff
time function can solve some cases where the objective of the query is to obtain a specific range of values but this has to be handled manually for each scenario. For more information please refer to the Snowflake documentation about Datediff.If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0011¶
Severity¶
Low
Description¶
Some options available in PostgreSQL for the sequence statement are not supported by Snowflake.
The unsupported options are:
Unlogged.
AS <data_type>.
MinValue.
MaxValue.
No MinValue.
No MaxValue.
Cache.
Cycle.
Owner By.
Code Example¶
Input code:¶
CREATE UNLOGGED SEQUENCE sequence_name;
Output code:¶
--** SSC-FDM-PG0009 - THE SEQUENCE NEXTVAL PROPERTY SNOWFLAKE DOES NOT GUARANTEE GENERATING SEQUENCE NUMBERS WITHOUT GAPS. **
CREATE UNLOGGED !!!RESOLVE EWI!!! /*** SSC-EWI-PG0011 - 'UNLOGGED' IS NOT SUPPORTED BY SNOWFLAKE. ***/!!! SEQUENCE sequence_name;
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0010¶
Severity¶
Low
Description¶
When a temporary sequence is created in PostgreSQL, it is only created for the active session and is automatically deleted when you log out of the session. However, this functionality is not available in Snowflake, so it is generated as a normal sequence. When executed, a similar sequence name may already exist, which will cause an error for an existing object.
Code Example¶
Input code:¶
CREATE TEMPORARY SEQUENCE sequence1;
CREATE TEMP SEQUENCE sequence2;
Output code:¶
--** SSC-FDM-PG0009 - THE SEQUENCE NEXTVAL PROPERTY SNOWFLAKE DOES NOT GUARANTEE GENERATING SEQUENCE NUMBERS WITHOUT GAPS. **
CREATE TEMPORARY !!!RESOLVE EWI!!! /*** SSC-EWI-PG0010 - CREATE TEMPORARY SEQUENCE IS NOT SUPPORTED BY SNOWFLAKE. ***/!!! SEQUENCE sequence1;
--** SSC-FDM-PG0009 - THE SEQUENCE NEXTVAL PROPERTY SNOWFLAKE DOES NOT GUARANTEE GENERATING SEQUENCE NUMBERS WITHOUT GAPS. **
CREATE TEMP !!!RESOLVE EWI!!! /*** SSC-EWI-PG0010 - CREATE TEMPORARY SEQUENCE IS NOT SUPPORTED BY SNOWFLAKE. ***/!!! SEQUENCE sequence2;
Recommendations¶
If you have a creation problem, you can try to rename the sequence to avoid collisions.
If you need more support, you can email us at snowconvert-support@snowflake.com.
SSC-EWI-PG0004¶
Severity¶
Medium
Description¶
The exclude constraint used in PostgreSQL is not supported by Snowflake.
Code Example¶
Input Code:¶
CREATE TABLE Table1 (
id int,
EXCLUDE USING gist (id WITH &&)
);
Output Code:¶
CREATE TABLE Table1 (
id int,
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0004 - EXCLUDE CONSTRAINT IS NOT SUPPORTED IN SNOWFLAKE. ***/!!!
EXCLUDE USING gist (id WITH &&)
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": { "major": 0, "minor": 0, "patch": "0" }, "attributes": { "component": "postgresql", "convertedOn": "09/17/2024" }}';
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-EWI-PG0014¶
Severity¶
Medium
Description¶
In Snowflake, the FETCH cursor statement always fetches the next row in the cursor. When transforming the code, SnowConvert will transform cursor orientations that are equivalent to a FETCH NEXT as they are functionally equivalent in Snowflake, namely:
FETCH NEXT
FETCH FORWARD
FETCH RELATIVE 1
FETCH
(no orientation specified)
Any other orientation is unsupported and the FETCH statement will be marked with this EWI to reflect that.
Code Example¶
Input Code:¶
CREATE OR REPLACE PROCEDURE cursor_test()
AS $$
BEGIN
FETCH FORWARD FROM cursor1 INTO my_var;
FETCH FIRST FROM cursor1 INTO my_var;
FETCH LAST FROM cursor1 INTO my_var;
END;
$$;
Output Code:¶
CREATE OR REPLACE PROCEDURE cursor_test ()
RETURNS VARCHAR
AS $$
BEGIN
FETCH
cursor1 INTO my_var;
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0014 - SNOWFLAKE SCRIPTING CURSORS DO NOT SUPPORT FETCH ORIENTATION. ***/!!!
FETCH FIRST FROM cursor1 INTO my_var;
!!!RESOLVE EWI!!! /*** SSC-EWI-PG0014 - SNOWFLAKE SCRIPTING CURSORS DO NOT SUPPORT FETCH ORIENTATION. ***/!!!
FETCH LAST FROM cursor1 INTO my_var;
END;
$$;
Recommendations¶
If you need more support, you can email us at snowconvert-support@snowflake.com