SnowConvert AI - Redshift - SQL Statements¶
Translation reference for all the supported statements by SnowConvert AI for Redshift.
CALL¶
Description¶
Runs a stored procedure. The CALL command must include the procedure name and the input argument values. You must call a stored procedure by using the CALL statement. (Redshift SQL Language Reference CALL).
Grammar Syntax¶
Sample Source Patterns¶
Base scenario¶
Input Code:¶
Redshift¶
Output Code:¶
Redshift¶
Call using Output Parameters Mode (INOUT, OUT)¶
Input Code:¶
Redshift¶
Output Code:¶
Redshift¶
Known Issues¶
Output parameters from calls outside procedures won’t work.
CREATE DATABASE¶
Grammar Syntax¶
For more information please refer to Redshift CREATE DATABASE documentation.
Sample Source Patterns¶
Basic samples¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Collate Clause¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Connection Limit Clause¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Warning
The connection limit clause is removed since the connection concurrency in Snowflake is managed by warehouse. For more information, see the Snowflake MAX_CONCURRENCY_LEVEL parameter.
From ARN Clause¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Warning
This clause is removed since it is used to reference Amazon Resources, not valid in Snowflake.
Owner Clause¶
Input Code¶
Redshift¶
Output Code¶
Snowflake¶
Warning
Please be aware that for this case, the owner clause is removed from the code since Snowflake databases are owned by roles, not individual users. For more information please refer to Snowflake GRANT OWNERSHIP documentation.
Isolation Level Clause¶
Input Code¶
Redshift¶
Output Code¶
Snowflake¶
Note
The transformation for Isolation Level is planned to be delivered in the future.
Related EWIs¶
SSC-EWI-0073: Pending Functional Equivalence Review
CREATE EXTERNAL TABLE¶
Description ¶
Currently SnowConvert AI is transforming CREATE EXTERNAL TABLES to regular tables, that implies additional effort because data stored in external RedShift tables must be transferred to the Snowflake database.
Grammar Syntax ¶
See the Redshift CREATE EXTERNAL TABLE specification for this syntax.
Sample Source Patterns¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Create External Table AS¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Recommendations¶
For the usage of Create External Table in Snowflake you may refer to Snowflake’s documentation.
Related EWIs¶
SSC-FDM-0004: External table translated to regular table
CREATE MATERIALIZED VIEW¶
Description¶
In SnowConvert AI, Redshift Materialized Views are transformed into Snowflake Dynamic Tables. To properly configure Dynamic Tables, two essential parameters must be defined: TARGET_LAG and WAREHOUSE. If these parameters are left unspecified in the configuration options, SnowConvert AI will default to preassigned values during the conversion, as demonstrated in the example below.
For more information, see the Redshift CREATE MATERIALIZED VIEW documentation.
For details on the necessary parameters, see the Snowflake CREATE DYNAMIC TABLE documentation.
Grammar Syntax¶
The following is the SQL syntax to create a view in Amazon Redshift. See the Redshift CREATE MATERIALIZED VIEW specification for this syntax.
Sample Source Patterns¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Note
For the table attributes documentation you can check de following documentation:
Warning
The BACKUP and AUTO REFRESH clauses are deleted since they are not applicable in a Snowflake’s Dynamic Table
Related Ewis¶
SSC-FDM-0031: Dynamic Table required parameters set by default
CREATE SCHEMA¶
Grammar Syntax¶
For more information please refer to Redshift CREATE SCHEMA documentation.
Sample Source Patterns¶
Basic samples¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Quota Clause¶
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Note
In Snowflake is not allowed to define a quota per scheme. Storage management is done at the account and warehouse level, and Snowflake handles it automatically. For this reason it is removed from the code.
Related EWIs¶
There are no known issues.
CREATE FUNCTION¶
Description¶
This command defines a user-defined function (UDF) within the database. These functions encapsulate reusable logic that can be invoked within SQL queries.
Grammar Syntax¶
The following is the SQL syntax to create a view in Amazon Redshift. See the Redshift CREATE VIEW specification for this syntax.
SQL Language¶
Volatility category¶
In Snowflake, VOLATILE and IMMUTABLE function volatility are functionally equivalent. Given that STABLE is inherently transformed to the default VOLATILE behavior, explicit use of STABLE will be deleted.
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Python Language¶
Within the SnowConvert AI scope, the Python language for CREATE FUNCTION statements is not supported. Consequently, the language plpythonu will be flagged with an EWI (SSC-EWI-0073), and its body could appear with parsing errors.
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Related EWIs¶
There are no known issues.
CREATE VIEW¶
Description¶
This command creates a view in a database, which is run every time the view is referenced in a query. Using the WITH NO SCHEMA BINDING clause, you can create views to an external table or objects that don’t exist yet. This clause, however, requires you to specify the qualified name of the object or table that you are referencing.
Grammar Syntax¶
The following is the SQL syntax to create a view in Amazon Redshift. See the Redshift CREATE VIEW specification for this syntax.
Sample Source Patterns¶
Considering the obligatory and optional clauses in Redshifts command, the output after migration to Snowflake is very similar.
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
There are some exceptions, however, of one unsupported clause from Redshift, therefore an EWI was implemented to cover this case.
Related EWIs¶
SSC-EWI-RS0003: With no schema binding statement is not supported in Snowflake.
DELETE¶
Description¶
Deletes rows from tables. (Redshift SQL Language Reference Delete Statement).
Note
This syntax is fully supported in Snowflake.
Grammar Syntax¶
Sample Source Patterns¶
Setup data¶
Redshift¶
From Clause¶
Update a table by referencing information from other tables. In Redshift, the FROM keyword is optional, but in Snowflake, it is mandatory. Therefore, it will be added in cases where it’s missing.
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
Where Clause¶
Restricts updates to rows that match a condition. When the condition returns true, the specified SET columns are updated. The condition can be a simple predicate on a column or a condition based on the result of a subquery. This clause is fully equivalent in Snowflake.
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
1 |
Alice |
Sales |
2 |
2 |
Bob |
Sales |
1 |
3 |
Charlie |
Sales |
1 |
7 |
Grace |
Engineering |
6 |
8 |
Helen |
Engineering |
7 |
9 |
Ivy |
Engineering |
7 |
10 |
John |
Sales |
3 |
11 |
Joe |
Engineering |
5 |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
1 |
Alice |
Sales |
2 |
2 |
Bob |
Sales |
1 |
3 |
Charlie |
Sales |
1 |
7 |
Grace |
Engineering |
6 |
8 |
Helen |
Engineering |
7 |
9 |
Ivy |
Engineering |
7 |
10 |
John |
Sales |
3 |
11 |
Joe |
Engineering |
5 |
Using Clause¶
This clause introduces a list of tables when additional tables are referenced in the WHERE clause condition. This clause is fully equivalent in Snowflake.
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
4 |
David |
Marketing |
2 |
5 |
Eve |
Marketing |
4 |
6 |
Frank |
Marketing |
4 |
7 |
Grace |
Engineering |
6 |
8 |
Helen |
Engineering |
7 |
9 |
Ivy |
Engineering |
7 |
11 |
Joe |
Engineering |
5 |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
4 |
David |
Marketing |
2 |
5 |
Eve |
Marketing |
4 |
6 |
Frank |
Marketing |
4 |
7 |
Grace |
Engineering |
6 |
8 |
Helen |
Engineering |
7 |
9 |
Ivy |
Engineering |
7 |
11 |
Joe |
Engineering |
5 |
WITH clause¶
This clause specifies one or more Common Table Expressions (CTE). The output column names are optional for non-recursive CTEs, but mandatory for recursive ones.
Since this clause cannot be used in an DELETE statement, it is transformed into temporary tables with their corresponding queries. After the DELETE statement is executed, these temporary tables are dropped to clean up, release resources, and avoid name collisions when creating tables within the same session. Additionally, if a regular table with the same name exists, it will take precedence again, since the temporary table has priority over any other table with the same name in the same session.
Non-Recursive CTE¶
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
4 |
David |
Marketing |
2 |
5 |
Eve |
Marketing |
4 |
6 |
Frank |
Marketing |
4 |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
4 |
David |
Marketing |
2 |
5 |
Eve |
Marketing |
4 |
6 |
Frank |
Marketing |
4 |
Recursive CTE¶
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
1 |
Alice |
Sales |
2 |
2 |
Bob |
Sales |
1 |
3 |
Charlie |
Sales |
1 |
10 |
John |
Sales |
3 |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
DEPARTMENT |
MANAGER_ID |
|---|---|---|---|
1 |
Alice |
Sales |
2 |
2 |
Bob |
Sales |
1 |
3 |
Charlie |
Sales |
1 |
10 |
John |
Sales |
3 |
Delete Materialized View¶
In Redshift, you can apply the DELETE statement to materialized views used for streaming ingestion. In Snowflake, these views are transformed into dynamic tables, and the DELETE statement cannot be used on dynamic tables. For this reason, an EWI will be added.
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
Known Issues ¶
Replicating the functionality of the
WITHclause requires creating temporary tables mirroring each Common Table Expression (CTE). However, this approach fails if a temporary table with the same name already exists within the current session, causing an error.
Related EWIs¶
SSC-FDM-0031: Dynamic Table required parameters set by default.
SSC-EWI-RS0008: Materialized view is transformed into a dynamic table, and the DELETE statement cannot be used on dynamic tables in Snowflake.
EXECUTE¶
Description¶
The
EXECUTEIMMEDIATEstatement builds and runs a dynamic SQL statement in a single operation.Native dynamic SQL uses the
EXECUTEIMMEDIATEstatement to process most dynamic SQL statements. (Redshift Language Reference EXECUTE Statement)
Grammar Syntax¶
Sample Source Patterns¶
Concated Example
Input Code
Redshift¶
Output Code
Snowflake¶
Function Transformation¶
Input Code¶
Redshift¶
Output Code¶
Snowflake¶
Error In Query Parsing¶
Input Code¶
Redshift¶
Output Code¶
Snowflake¶
INTO Clause¶
Input Code¶
Redshift¶
Output Code¶
Snowflake¶
Known Issues¶
1. Execution results cannot be stored in variables.¶
SnowScripting does not support INTO nor BULK COLLECT INTO clauses. For this reason, results will need to be passed through other means.
2. Dynamic SQL Execution queries may be marked incorrectly as non-runnable.¶
In some scenarios there an execute statement may be commented regardless of being safe or non-safe to run so please take this into account:
Related EWIs¶
SSC-EWI-0027: Variable with invalid query.
SSC-EWI-0030: The statement below has usages of dynamic SQL.
INSERT¶
Description¶
Inserts new rows into a table. (Redshift SQL Language Reference Insert Statement).
Warning
This syntax is partially supported in Snowflake.
Grammar Syntax¶
Sample Source Patterns¶
Setup data¶
Redshift¶
Default Values¶
It inserts a complete row with its default values. If any columns do not have default values, NULL values are inserted in those columns.
This clause cannot specify individual columns; it always inserts a complete row with its default values. Additionally, columns with the NOT NULL constraint cannot be included in the table definition. To replicate this behavior in Snowflake, SnowConvert AI insert a column with a DEFAULT value in the table. This action inserts a complete row, using the default value for every column.
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
NULL |
20000 |
Marketing |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
NULL |
20000 |
Marketing |
Query¶
Insert one or more rows into the table by using a query. All rows produced by the query will be inserted into the table. The query must return a column list that is compatible with the table’s columns, although the column names do not need to match. This functionality is fully equivalent in Snowflake.
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Grace Lee |
32000 |
Operations |
2 |
Hannah Gray |
26000 |
Finance |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Grace Lee |
32000 |
Operations |
2 |
Hannah Gray |
26000 |
Finance |
Known Issues ¶
Certain expressions cannot be used in the VALUES clause in Snowflake. For example, in Redshift, the JSON_PARSE function can be used within the VALUES clause to insert a JSON value into a SUPER data type. In Snowflake, however, the PARSE_JSON function cannot be used in the VALUES clause to insert a JSON value into a VARIANT data type. Instead, a query can be used in place of the VALUES clause. For more details, please refer to the Snowflake documentation. You can also check the following article for further information.
Related EWIs¶
There are no known issues.
MERGE¶
Grammar Syntax¶
For more information please refer to Redshift MERGE documentation.
Sample Source Patterns¶
UPDATE - INSERT¶
There are no differences between both languages. The code is kept in its original form.
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
DELETE - INSERT¶
There are no differences between both languages. The code is kept in its original form.
Input Code:¶
Redshift¶
Output Code:¶
Snowflake¶
REMOVE DUPLICATES¶
The REMOVE DUPLICATES clause is not supported in Snowflake, however, there is a workaround that could emulate the original behavior.
The output code will have three new statements:
A TEMPORARY TABLE with the duplicate values from the source and target table that matches the condition
An INSERT statement that adds the pending values to the target table after the merge
A DROP statement that drops the generated temporary table.
These are necessary since the DROP DUPLICATES behavior removes the duplicate values from the target table and then inserts the values that match the condition from the source table.
Input Code:¶
Redshift¶
Results¶
ID |
NAME |
|---|---|
30 |
Daisy |
22 |
Clarence |
30 |
Tony |
11 |
Alice |
23 |
David |
Output Code:¶
Snowflake¶
Results¶
ID |
NAME |
|---|---|
22 |
Clarence |
30 |
Tony |
30 |
Daisy |
11 |
Alice |
23 |
David |
Known Issues¶
There are no known issues.
Related EWIs¶
SSC-EWI-RS0009: Semantic information not found for the source table.
SSC-FDM-RS0005: Redshift MERGE rejects duplicate source rows. Snowflake allows them, which may produce different results.
UPDATE¶
Description¶
Updates values in one or more table columns when a condition is satisfied. (Redshift SQL Language Reference Update Statement).
Note
This syntax is fully supported in Snowflake.
Grammar Syntax¶
Sample Source Patterns¶
Setup data¶
Redshift¶
Alias¶
Although Snowflake’s grammar does not specify that a table alias can be used, it’s valid code in Snowflake.
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Alice |
505000 |
HR |
2 |
Bob |
600000 |
Engineering |
3 |
Charlie |
700000 |
Engineering |
4 |
David |
405000 |
Marketing |
5 |
Eve |
455000 |
HR |
6 |
Frank |
750000 |
Engineering |
7 |
Grace |
650000 |
Engineering |
8 |
Helen |
395000 |
Marketing |
9 |
Ivy |
485000 |
HR |
10 |
Jack |
425000 |
Engineering |
11 |
Ken |
700000 |
Marketing |
12 |
Liam |
600000 |
Engineering |
13 |
Mona |
475000 |
HR |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Alice |
505000 |
HR |
2 |
Bob |
600000 |
Engineering |
3 |
Charlie |
700000 |
Engineering |
4 |
David |
405000 |
Marketing |
5 |
Eve |
455000 |
HR |
6 |
Frank |
750000 |
Engineering |
7 |
Grace |
650000 |
Engineering |
8 |
Helen |
395000 |
Marketing |
9 |
Ivy |
485000 |
HR |
10 |
Jack |
425000 |
Engineering |
11 |
Ken |
700000 |
Marketing |
12 |
Liam |
600000 |
Engineering |
13 |
Mona |
475000 |
HR |
WITH clause¶
This clause specifies one or more Common Table Expressions (CTE). The output column names are optional for non-recursive CTEs, but mandatory for recursive ones.
Since this clause cannot be used in an UPDATE statement, it is transformed into temporary tables with their corresponding queries. After the UPDATE statement is executed, these temporary tables are dropped to clean up, release resources, and avoid name collisions when creating tables within the same session. Additionally, if a regular table with the same name exists, it will take precedence again, since the temporary table has priority over any other table with the same name in the same session.
Non-Recursive CTE¶
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Alice |
500000 |
HR |
2 |
Bob |
600000 |
Engineering |
3 |
Charlie |
700000 |
Engineering |
4 |
David |
546923 |
Marketing |
5 |
Eve |
546923 |
HR |
6 |
Frank |
750000 |
Engineering |
7 |
Grace |
650000 |
Engineering |
8 |
Helen |
546923 |
Marketing |
9 |
Ivy |
546923 |
HR |
10 |
Jack |
546923 |
Engineering |
11 |
Ken |
700000 |
Marketing |
12 |
Liam |
600000 |
Engineering |
13 |
Mona |
546923 |
HR |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Alice |
500000 |
HR |
2 |
Bob |
600000 |
Engineering |
3 |
Charlie |
700000 |
Engineering |
4 |
David |
546923 |
Marketing |
5 |
Eve |
546923 |
HR |
6 |
Frank |
750000 |
Engineering |
7 |
Grace |
650000 |
Engineering |
8 |
Helen |
546923 |
Marketing |
9 |
Ivy |
546923 |
HR |
10 |
Jack |
546923 |
Engineering |
11 |
Ken |
700000 |
Marketing |
12 |
Liam |
600000 |
Engineering |
13 |
Mona |
546923 |
HR |
Recursive CTE¶
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Alice |
526666 |
HR |
2 |
Bob |
670000 |
Engineering |
3 |
Charlie |
773333 |
Engineering |
4 |
David |
433333 |
Marketing |
5 |
Eve |
475000 |
HR |
6 |
Frank |
825000 |
Engineering |
7 |
Grace |
721666 |
Engineering |
8 |
Helen |
423000 |
Marketing |
9 |
Ivy |
506000 |
HR |
10 |
Jack |
484000 |
Engineering |
11 |
Ken |
743333 |
Marketing |
12 |
Liam |
670000 |
Engineering |
13 |
Mona |
495668 |
HR |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Alice |
526667 |
HR |
2 |
Bob |
670000 |
Engineering |
3 |
Charlie |
773333 |
Engineering |
4 |
David |
433333 |
Marketing |
5 |
Eve |
475000 |
HR |
6 |
Frank |
825000 |
Engineering |
7 |
Grace |
721667 |
Engineering |
8 |
Helen |
423000 |
Marketing |
9 |
Ivy |
506000 |
HR |
10 |
Jack |
484000 |
Engineering |
11 |
Ken |
743333 |
Marketing |
12 |
Liam |
670000 |
Engineering |
13 |
Mona |
495667 |
HR |
SET DEFAULT values¶
Input Code:¶
Redshift¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Alice |
20000 |
Sales |
2 |
Bob |
600000 |
Engineering |
3 |
Charlie |
700000 |
Engineering |
4 |
David |
400000 |
Marketing |
5 |
Eve |
20000 |
Sales |
6 |
Frank |
750000 |
Engineering |
7 |
Grace |
650000 |
Engineering |
8 |
Helen |
390000 |
Marketing |
9 |
Ivy |
20000 |
Sales |
10 |
Jack |
420000 |
Engineering |
11 |
Ken |
700000 |
Marketing |
12 |
Liam |
600000 |
Engineering |
13 |
Mona |
20000 |
Sales |
Output Code:¶
Snowflake¶
Result¶
ID |
NAME |
SALARY |
DEPARTMENT |
|---|---|---|---|
1 |
Alice |
20000 |
Sales |
2 |
Bob |
600000 |
Engineering |
3 |
Charlie |
700000 |
Engineering |
4 |
David |
400000 |
Marketing |
5 |
Eve |
20000 |
Sales |
6 |
Frank |
750000 |
Engineering |
7 |
Grace |
650000 |
Engineering |
8 |
Helen |
390000 |
Marketing |
9 |
Ivy |
20000 |
Sales |
10 |
Jack |
420000 |
Engineering |
11 |
Ken |
700000 |
Marketing |
12 |
Liam |
600000 |
Engineering |
13 |
Mona |
20000 |
Sales |
SET clause¶
It is responsible for modifying values in the columns. Similar to Snowflake, update queries with multiple matches per row will throw an error when the configuration parameter ERROR_ON_NONDETERMINISTIC_UPDATE is set to true. This flag works the same way in Snowflake, and it even uses the same name, ERROR_ON_NONDETERMINISTIC_UPDATE.
However, when this flag is turned off, no error is returned, and one of the matched rows is used to update the target row. The selected joined row is nondeterministic and arbitrary in both languages; the behavior may not be consistent across executions, which could lead to data inconsistencies.
Setup data:¶
Redshift¶
Input Code:¶
Redshift¶
Result¶
K |
V |
|---|---|
0 |
16 |
Output Code:¶
Snowflake¶
Result¶
K |
V |
|---|---|
0 |
14 |
Known Issues ¶
Update queries with multiple matches per row may cause data inconsistencies. Although both platforms have the flag ERROR_ON_NONDETERMINISTIC_UPDATE, these values will always be nondeterministic. Snowflake offers recommendations for handling these scenarios. See the Snowflake UPDATE examples for more details.
Replicating the functionality of the
WITHclause requires creating temporary tables mirroring each Common Table Expression (CTE). However, this approach fails if a temporary table with the same name already exists within the current session, causing an error.
Related EWIs¶
There are no known issues.