SnowConvert AI - PostgreSQL Functional Differences¶
Note
SnowConvert AI for PostgreSQL currently supports assessment and translation for TABLES and VIEWS. Although SnowConvert AI can recognize other types of statements, they are not fully supported.
If you need more support, you can email us at snowconvert-support@snowflake.com
SSC-FDM-PG0001¶
FOUND could have a different behavior in Snowflake in some scenarios.
Severity¶
Low
Description¶
The FOUND property in PostgreSQL is a property based on the last executed query, it can be affected by some statements such as INSERT, UPDATE, DELETE, MERGE, SELECT INTO, PERFORM, FETCH and FOR loops. To read more details about this property, this is PostgreSQL documentation.
In Snowflake there is not a direct translation for this property, for the following scenarios:
INSERTUPDATEDELETEMERGE
The converted code will be SQLFOUND Snowflake property (Here is the documentation) since it behaves like the PostgreSQL FOUND property.
For the other cases such as:
SELECT INTOPERFORMFETCH
The converted code will be a custom UDF (IS_FOUND_UDF) that behaves like the PostgreSQL FOUND property.
This happens because SQLFOUND changes its value only when at least one row is affected by the last executed query, if the last query does not change any row, it does not change.
While the IS_FOUND_UDF only works for statements that returns rows, if no row is returned it, it will return FALSE.
SQLFOUND Example¶
The last query affects a table, so the SQLFOUND is the closest to the PostgreSQL functionality.
IS_FOUND_UDF Example¶
The last query will return a row but does not change anything, so the IS_FOUND_UDF() is the closest to the PostgreSQL functionality.
IS_FOUND_UDF Source Code¶
Code Example¶
Insert Statement:¶
PostgreSQL¶
Snowflake¶
Update Statement:¶
PostgreSQL¶
Snowflake¶
Delete Statement:¶
PostgreSQL¶
Snowflake¶
Merge Statement:¶
PostgreSQL¶
Snowflake¶
Select Into Statement¶
PostgreSQL¶
Snowflake¶
Perform Statement:¶
PostgreSQL¶
Snowflake¶
Fetch Statement:¶
PostgreSQL¶
Snowflake¶
SSC-FDM-PG0002¶
Bpchar converted to varchar.
Description¶
This warning is added because bpchar type (“blank-padded char”) may have some functional equivalence difference compared to the varchar data type in Snowflake. However, both data types can store the values up to the “n” length of characters and consume storage for only the amount of actual data stored. The main difference occurs when there are blanks at the end of the data, where bpchar does not store them but snowflake does.
For this reason, we can use the RTRIM function so that these blanks are not stored. But there may be cases where the functionality is not completely equivalent.
Code Example¶
Input Code:¶
Column Definition¶
Explicit Cast¶
Generated Code:¶
Column Definition¶
Explicit Cast¶
Best Practices¶
The
rtrimfunction can resolve storage differences in case you want those blanks not to be stored. This case is handled in the explicit cast, however, there may be other scenarios where it has to be handled manually. For more information refer to the Snowflake documentation about RTRIM.
SSC-FDM-PG0003¶
Bytea Converted To Binary
Description¶
This warning is added because when the bytea data type is converted to binary the size limit is greatly reduced from 1GB to 8MB.
Code Example¶
Input Code:¶
Generated Code:¶
Best Practices¶
For more information refer to the Snowflake documentation about Binary Data Type.
SSC-FDM-PG0004¶
The date output format may vary
Description¶
The date output format may vary depending on the Timestamp type and the timestamp_output_format being used, see the Snowflake CURRENT_TIMESTAMP documentation.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
Samples¶
Example with CREATE TABLE.
Input Code:¶
PostgreSQL¶
Results¶
platform_id |
dt_update |
clock_timestamp |
|---|---|---|
1 |
2023-02-05 22:47:34.275 -0600 |
2023-02-05 23:16:15.754 -0600 |
Generated Code:¶
Snowflake¶
Results¶
PLATFORM_ID |
DT_UPDATE |
CURRENT_TIMESTAMP(3) |
|---|---|---|
1 |
2023-02-05 20:52:30.082000000 |
2023-02-05 21:20:31.593 |
Example with SELECT with clock_timestamp().
Input Code¶
PostgreSQL¶
Results¶
clock_timestamp |
|---|
2023-02-05 23:24:13.740 |
Generated Code¶
Snowflake¶
Results¶
CURRENT_TIMESTAMP(3) |
|---|
2023-02-05 21:29:24.258 |
SSC-FDM-PG0005¶
UNLOGGED Table is not supported in Snowflake; data written may have different performance.
Description¶
PostgreSQL’s UNLOGGED tables offer a significant speed advantage by skipping write-ahead logging (WAL). However, their data isn’t replicated to mirror instances. Snowflake doesn’t support this functionality, so the UNLOGGED clause will be commented out.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
SSC-FDM-PG0006¶
Set search path with multiple schemas.
Description¶
Set search path with multiple schemas is not supported in Snowflake, see the Snowflake USE SCHEMA documentation.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
SSC-FDM-PG0007¶
NULL is converted to ‘’ and may have a different behavior in Snowflake.
Severity¶
Low
Description¶
In PostgreSQL the removal of a comment is handled by using the NULL term. However, in Snowflake, a similar method for removing a comment is to assign the value of an empty string '' to provide the same result. This approach ensures that the comment is effectively mapped to an empty string with a similar behavior.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
SSC-FDM-PG0008¶
Select into unlogged tables are not supported by Snowflake.
Description¶
Select Into is not supported by Snowflake, this functionality was emulated with CREATE TABLE AS. In addition, Snowflake always uses transaction logs to protect tables and ensure data integrity and recoverability. Consequently, tables with the UNLOGGED option are not supported by Snowflake.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
SSC-FDM-PG0009¶
Sequence nextval property snowflake does not guarantee generating sequence numbers without gaps
Description¶
Snowflake does not guarantee generating sequence numbers without gaps. The generated numbers consistently increase in value (or decrease in value if the step size is negative) but are not necessarily contiguous.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
SSC-FDM-PG0010¶
Datatype of the left operand could not be determined. Results may vary due to the behavior of Snowflake’s bitwise function
Description¶
The bitwise operators << and >> are converted to the corresponding Snowflake functions BITSHIFTLEFT and BITSHIFTRIGHT. However, this transformation depends on knowing semantic information about the left operand, more specifically its datatype.
For shift operations involving integer left operands, the MOD function should be applied to the right operand to get equivalent results, as well as using the INTEGER_BITSHIFTLEFT_UDF helper for ensuring the equivalence of the shift left operation on integers. When the datatype of the left operand can not be determined, SnowConvert AI will generate this FDM to warn about the potential functional differences.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
Best Practices¶
Ensure the source code you migrate has no missing depedencies, by providing any missing object to SnowConvert AI the operands semantic information should be extracted correctly and this FDM should no longer appear
SSC-FDM-PG0011¶
The use of the COLLATE column constraint has been disabled for this pattern-matching condition
Description¶
This message is added when a pattern-matching condition uses arguments with COLLATE specifications, as they are not currently supported in Snowflake’s regular expression function. Consequently, the COLLATE clause must be disabled to use this function, which may result in differences in the results.
Code Example¶
Input Code:¶
PostgreSQL¶
Results¶
CI |
CS |
|---|---|
TRUE |
FALSE |
Output Code:
Snowflake¶
Results¶
CI |
CS |
|---|---|
FALSE |
FALSE |
Best Practices¶
If you require equivalence for these scenarios, you can manually add the following parameters to the function to achieve functional equivalence:
Parameter
Description
cCase-sensitive matching
iCase-insensitive matching
For more information please refer to the following link.
SSC-FDM-PG0012¶
NOT NULL constraint has been removed. Assigning NULL to this variable will no longer cause a failure.
Description¶
In PostgreSQL, specifying the NOT NULL constraint ensures that assigning a null value to a variable results in a runtime error. Since this clause does not exist in Snowflake, it is removed during transformation and assigning a NULL to this variable will no longer fail in execution.
Code Example¶
Input Code:¶
PostgreSQL¶
Result¶
[22004] ERROR: NULL cannot be assigned to variable “v_notnull” declared NOT NULL
Generated Code:
Snowflake
Result
Note
This assignment will not fail in Snowflake.
Best Practices¶
Review the procedure logic to ensure this variable is not assigned a
NULLvalue.
SSC-FDM-PG0013¶
Function syntactically supported by Snowflake but may have functional differences
Description¶
This functional difference message indicates that while Snowflake supports the function’s syntax (either directly or through an equivalent mapping), its behavior might be different from the original in some situations.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
Best Practices¶
Carefully evaluate the functional behavior for unexpected results, as differences may only occur in specific scenarios.
SSC-FDM-PG0014¶
Unknown Pseudotype transformed to Text Type
Description¶
This functional difference message indicates that UNKNOWN Pseudo Type used in PostgreSQL is not supported in Snowflake and is transformed to a Text Type.
Code Example¶
Input Code:¶
PostgreSQL¶
Generated Code:¶
Snowflake¶
Best Practices¶
Carefully evaluate the usages for the columns with Unknown Data Types, as differences may occur in specific scenarios.
SSC-FDM-PG0015¶
PSQL command is not applicable in Snowflake
Description¶
In Snowflake, PSQL commands are not applicable. While no longer needed for execution, SnowConvert AI retains the original PSQL command as a comment.
Example Code¶
Input Code: ¶
Generated Code: ¶
SSC-FDM-PG0016¶
Strongly typed array transformed to ARRAY without type checking.
Description¶
SnowConvert AI will add this warning because PostgreSQL supports arrays of any built-in or user-defined base type, enum type, composite type, range type, or domain, whereas Snowflake does not. In Snowflake, each value in a semi-structured array is of type VARIANT.
Example Code¶
Input Code: ¶
Generated Code: ¶
SSC-FDM-PG0017¶
User Defined function that returns a void was transformed to a Snowflake procedure.
Description¶
SnowConvert AI will generate a warning for any function that returns void. This is because functions returning void typically indicate a procedure rather than a value-producing operation, which can sometimes require special handling during conversion.
Example Code¶
Input Code: ¶
Generated Code: ¶
SSC-FDM-PG0018¶
Analyze statement is commented out, which is not applicable in Snowflake.
Description¶
SnowConvert AI flags ANALYZE statements with a warning and comments them out. While ANALYZE is used in PostgreSQL for collecting table statistics, Snowflake automatically manages this process, making the statement redundant and generally unnecessary post-conversion.
Example Code¶
Input Code: ¶
Generated Code: ¶
Best Practices¶
If you need more support, you can email us at snowconvert-support@snowflake.com