SnowConvert AI – Diferenças funcionais do Redshift

SSC-FDM-RS0001

Data storage option is not supported in Snowflake. Data distribution is automatically handled by Snowflake.

Descrição

No Snowflake, não é necessário definir explicitamente SORTKEY e DISTSTYLE ao migrar do Redshift, pois a arquitetura do Snowflake gerencia de modo inerente a distribuição e a otimização de dados. O Snowflake lida automaticamente com o particionamento e a indexação de dados, otimizando o desempenho das consultas sem exigir a configuração manual desses parâmetros.

Exemplo de código

Código de entrada:
Redshift
 CREATE TABLE table1 (
    col1 INTEGER
)
DISTSTYLE AUTO;

CREATE TABLE table2 (
    col1 INTEGER
)
SORTKEY AUTO;
Código gerado:
Snowflake
 CREATE TABLE table1 (
    col1 INTEGER
)
----** SSC-FDM-RS0001 - DISTSTYLE AUTO OPTION IS NOT SUPPORTED IN SNOWFLAKE. DATA STORAGE IS AUTOMATICALLY HANDLED BY SNOWFLAKE. **
--DISTSTYLE AUTO
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "09/17/2024" }}';

CREATE TABLE table2 (
    col1 INTEGER
)
----** SSC-FDM-RS0001 - SORTKEY AUTO OPTION IS NOT SUPPORTED IN SNOWFLAKE. DATA STORAGE IS AUTOMATICALLY HANDLED BY SNOWFLAKE. **
--SORTKEY AUTO
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "09/17/2024" }}';

Práticas recomendadas

  • É recomendável avaliar o uso de CLUSTERBY no Snowflake durante a migração do Redshift, pois isso pode melhorar o desempenho das consultas, otimizando a localidade dos dados para colunas consultadas com frequência.

  • Se precisar de mais suporte, envie um e-mail para snowconvert-support@snowflake.com

SSC-FDM-RS0002

The performance of CLUSTER BY in Snowflake may vary compared to the performance of SORTKEY in Redshift.

Descrição

SORTKEY (excluindo SORTKEY AUTO) no Amazon Redshift são análogos ao CLUSTER BY no Snowflake. No entanto, as implicações de desempenho podem variar devido às diferenças arquitetônicas entre o Redshift e o Snowflake.

  • SORTKEY melhora o desempenho mantendo os dados em ordem classificada com base em colunas especificadas. Isso é particularmente útil para consultas de intervalo e operações de ordenação.

  • O CLUSTER BY no Snowflake organiza os dados em blocos com base em colunas designadas, auxiliando em tarefas de filtragem e agregação. No entanto, ele é menos rigoroso quanto à ordenação em comparação com SORTKEY.

Compreender esses mecanismos é crucial para otimizar o desempenho em cada plataforma respectiva.

Exemplo de código

Código de entrada:
Redshift
 CREATE TABLE table1 (
    col1 INTEGER
)
SORTKEY (col1);

CREATE TABLE table2 (
    col1 INTEGER SORTKEY
);
Código gerado:
Snowflake
 CREATE TABLE table1 (
    col1 INTEGER
)
--** SSC-FDM-RS0002 - THE PERFORMANCE OF CLUSTER BY IN SNOWFLAKE MAY VARY COMPARED TO THE PERFORMANCE OF SORTKEY IN REDSHIFT **
CLUSTER BY (col1)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "09/17/2024" }}'
;

CREATE TABLE table2 (
    col1 INTEGER
)
--** SSC-FDM-RS0002 - THE PERFORMANCE OF CLUSTER BY IN SNOWFLAKE MAY VARY COMPARED TO THE PERFORMANCE OF SORTKEY IN REDSHIFT **
CLUSTER BY (col1)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "09/17/2024" }}';

Práticas recomendadas

  • Benchmark after migration: Run representative queries on both platforms to compare performance, as CLUSTER BY uses micro-partitioning rather than physical sort order.

  • Consider automatic clustering: For large tables with frequent queries on specific columns, enable automatic clustering in Snowflake.

  • Se precisar de mais suporte, envie um e-mail para snowconvert-support@snowflake.com

SSC-FDM-RS0003

Pending SnowConvert AI translation for Redshift foreign key constraints.

Descrição

Pending SnowConvert AI translation for Redshift foreign key constraints. Snowflake supports foreign key constraints, but they are not enforced and serve only as referential integrity metadata. This is a SnowConvert AI limitation, not a Snowflake platform limitation.

Exemplo de código

Código de entrada:
Redshift
 CREATE TABLE TABLE1 (
    id INTEGER,
    PRIMARY KEY (id)
);

CREATE TABLE TABLE2 (
	id INTEGER,
	id_table1 INTEGER,
	FOREIGN KEY (id_table1) REFERENCES TABLE1 (col1)
);
Código gerado:
Snowflake
 CREATE TABLE TABLE1 (
    id INTEGER,
    PRIMARY KEY (id)
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "09/26/2024" }}';

CREATE TABLE TABLE2 (
	id INTEGER,
	id_table1 INTEGER
--	                 ,
--    --** SSC-FDM-RS0003 - PENDING SNOWCONVERT AI TRANSLATION FOR REDSHIFT FOREIGN KEY CONSTRAINTS. **
--	FOREIGN KEY (id_table1) REFERENCES TABLE1 (col1)
)
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "09/26/2024" }}';

Práticas recomendadas

  • Você pode alterar tabelas manualmente com chaves estrangeiras e adicioná-las.

 ALTER TABLE TABLE2 ADD CONSTRAINT
FOREIGN KEY (id_table1) REFERENCES TABLE1 (col1)

SSC-FDM-RS0004

É possível que a data esteja incorreta e o Snowflake não aceita datas incorretas.

Descrição

No Snowflake, usar TO_DATE com uma cadeia de caracteres de data inválida (como «20010631») resulta em um erro porque ele impõe uma validação estrita, rejeitando qualquer data inexistente. Em contraste, TO_DATE do Redshift pode ajustar essas datas inválidas para a data válida mais próxima (por exemplo, de 31 de junho para 1º de julho) se o parâmetro is_strict estiver definido como falso. Essa diferença destaca como o Snowflake prioriza a integridade dos dados ao não corrigir automaticamente datas inválidas, enquanto o Redshift permite mais flexibilidade no tratamento de datas.

Exemplo de código

Código de entrada:
Redshift
 SELECT TO_DATE('20010631', 'YYYYMMDD', FALSE);
Código gerado:
Snowflake
 SELECT
TRY_TO_DATE(/*** SSC-FDM-RS0004 - INVALID DATES WILL CAUSE ERRORS IN SNOWFLAKE ***/ '20010631', 'YYYYMMDD');

Práticas recomendadas

SSC-FDM-RS0005

Redshift MERGE rejects duplicate source rows. Snowflake allows them, which may produce different results.

Descrição

In Redshift, the MERGE statement throws an error when the source table contains duplicate rows matching the join condition. Snowflake allows MERGE to execute with duplicate source rows, which may produce non-deterministic results when multiple source rows match the same target row.

Exemplo de código

Código de entrada:
Redshift
 MERGE INTO target USING source ON target.id = source.id
WHEN MATCHED THEN DELETE
WHEN NOT MATCHED THEN INSERT VALUES (source.id, source.name);
Código gerado:
Snowflake
 --** SSC-FDM-RS0005 - REDSHIFT MERGE STATEMENT REJECTS DUPLICATE SOURCE ROWS. SNOWFLAKE ALLOWS DUPLICATES, WHICH MAY PRODUCE NON-DETERMINISTIC RESULTS. **
MERGE INTO target USING source ON target.id = source.id
WHEN MATCHED THEN DELETE
WHEN NOT MATCHED THEN INSERT VALUES (source.id, source.name);

Práticas recomendadas

  • Deduplicate source data: Add a QUALIFY ROW_NUMBER() OVER (PARTITION BY join_key ORDER BY ...) = 1 to the source subquery to ensure each target row matches at most one source row.

  • Validate results: After migration, compare MERGE output row counts between Redshift and Snowflake to detect non-deterministic behavior.

  • Se precisar de mais suporte, envie um e-mail para snowconvert-support@snowflake.com

SSC-FDM-RS0006

Called procedure contains usages of COMMIT/ROLLBACK. Modifying the current transaction in child scopes is not supported in Snowflake.

Descrição

No Redshift, é permitido usar as instruções COMMIT e ROLLBACK dentro de um procedimento para tornar permanentes ou descartar as alterações em uma transação que foi aberta em um escopo externo.

O Snowflake trabalha com o conceito de transações com escopo, que trata cada chamada de procedimento como uma transação separada. Isso limita os efeitos das instruções COMMIT e ROLLBACK ao escopo do procedimento em que são declaradas.

A diferença funcional mencionada será alertada com esta FDM quando chamadas a um procedimento com COMMIT ou ROLLBACK forem detectadas pelo SnowConvert.

Exemplo de código

Código de entrada:
Redshift
 CREATE OR REPLACE PROCEDURE inner_transaction_procedure(a int)
    LANGUAGE plpgsql
    AS $$
BEGIN
    INSERT INTO transaction_values_test values (a);
    ROLLBACK;
    INSERT INTO transaction_values_test values (a + 1);
END
$$;

CREATE OR REPLACE PROCEDURE outer_transaction_procedure(a int)
    LANGUAGE plpgsql
    AS $$
BEGIN
    -- This insert is also affected by the ROLLBACK in inner_transaction_procedure
    INSERT INTO transaction_values_test values (a);
    CALL inner_transaction_procedure(a + 3);
    COMMIT;
END
$$;

CALL outer_transaction_procedure(10);
Código gerado:
Snowflake
 CREATE OR REPLACE PROCEDURE inner_transaction_procedure (a int)
RETURNS VARCHAR
    LANGUAGE SQL
    COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "03/03/2025",  "domain": "test" }}'
    AS $$
BEGIN
    BEGIN TRANSACTION;
    INSERT INTO transaction_values_test
    values (:a);
    ROLLBACK;
    BEGIN TRANSACTION;
    INSERT INTO transaction_values_test
    values (:a + 1);
    COMMIT;
END
$$;

CREATE OR REPLACE PROCEDURE outer_transaction_procedure (a int)
RETURNS VARCHAR
    LANGUAGE SQL
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "03/03/2025",  "domain": "test" }}'
    AS $$
BEGIN
    BEGIN TRANSACTION;
    -- This insert is also affected by the ROLLBACK in inner_transaction_procedure
    INSERT INTO transaction_values_test
    values (:a);
    --** SSC-FDM-RS0006 - CALLED PROCEDURE CONTAINS USAGES OF COMMIT/ROLLBACK. MODIFYING THE CURRENT TRANSACTION IN CHILD SCOPES IS NOT SUPPORTED IN SNOWFLAKE **
    CALL inner_transaction_procedure(:a + 3);
    COMMIT;
END
$$;

CALL outer_transaction_procedure(10);

Práticas recomendadas

  • Refactor transaction control: Move COMMIT and ROLLBACK statements into the outermost procedure or use scoped transactions where supported.

  • Use caller’s rights: Ensure the calling procedure manages the transaction boundary, as Snowflake’s scoped transactions isolate child procedure changes.

  • Se precisar de mais suporte, envie um e-mail para snowconvert-support@snowflake.com

SSC-FDM-RS0007

DDL statements perform an automatic COMMIT in Snowflake. ROLLBACK will not undo DDL-committed changes.

Descrição

No Snowflake, as instruções DDL executam um commit automático após a execução delas, tornando permanentes todas as alterações na transação atual, o que significa que elas não podem ser descartadas por uma ROLLBACK.

Quando uma instrução ROLLBACK é encontrada em um procedimento que também contém uma instrução DDL, o SnowConvert AI gera esta FDM para informar sobre o comportamento da confirmação automática da DDL.

Exemplo de código

Código de entrada:
Redshift
 CREATE OR REPLACE PROCEDURE rollback_ddl(a int)
    LANGUAGE plpgsql
    AS $$
BEGIN
    INSERT INTO transaction_values_test values (a);
    CREATE TABLE someRollbackTable
    (
        col1 INTEGER
    );

    INSERT INTO someRollbackTable values (a);
    ROLLBACK;
END
$$;

CALL rollback_ddl(10);
Código gerado:
Snowflake
 CREATE OR REPLACE PROCEDURE rollback_ddl (a int)
RETURNS VARCHAR
    LANGUAGE SQL
    COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "03/03/2025",  "domain": "test" }}'
    AS $$
BEGIN
    BEGIN TRANSACTION;
    INSERT INTO transaction_values_test
    values (:a);
    CREATE TABLE someRollbackTable
    (
        col1 INTEGER
    );
    BEGIN TRANSACTION;
    INSERT INTO someRollbackTable
    values (:a);
    --** SSC-FDM-RS0007 - DDL STATEMENTS PERFORM AN AUTOMATIC COMMIT IN SNOWFLAKE. ROLLBACK WILL NOT UNDO DDL-COMMITTED CHANGES **
    ROLLBACK;
END
$$;

CALL rollback_ddl(10);

Práticas recomendadas

  • Separate DDL from DML transactions: Move DDL statements outside the transaction block, or execute them before BEGIN TRANSACTION to avoid implicit commits affecting DML operations.

  • Use conditional logic: If DDL creation is conditional, check for object existence with IF NOT EXISTS to avoid unnecessary autocommits.

  • Se precisar de mais suporte, envie um e-mail para snowconvert-support@snowflake.com

SSC-FDM-RS0008

Snowflake uses autocommit by default. The NONATOMIC option is not supported in Snowflake.

Descrição

In Redshift, the NONATOMIC option on CREATE PROCEDURE allows individual statements within the procedure to commit independently. In Snowflake, autocommit is the default behavior — each statement is automatically committed unless wrapped in an explicit BEGIN TRANSACTION block. The NONATOMIC keyword is removed during migration because Snowflake’s autocommit provides equivalent semantics.

Exemplo de código

Código de entrada:
Redshift
 CREATE OR REPLACE PROCEDURE SP_NONATOMIC()
NONATOMIC 
AS 
$$
    BEGIN
        NULL;
    END;
$$ 
LANGUAGE plpgsql;
Código gerado:
Snowflake
 CREATE OR REPLACE PROCEDURE SP_NONATOMIC ()
RETURNS VARCHAR
----** SSC-FDM-RS0008 - SNOWFLAKE USES AUTOCOMMIT BY DEFAULT. THE NONATOMIC OPTION IS NOT SUPPORTED IN SNOWFLAKE. **
--NONATOMIC
LANGUAGE SQL
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "02/10/2025",  "domain": "test" }}'
AS
$$
    BEGIN
        NULL;
    END;
$$;

Práticas recomendadas

  • Verify transaction behavior: If the original Redshift procedure relied on NONATOMIC for partial commits, test the migrated Snowflake procedure to confirm that autocommit provides the expected semantics.

  • Add explicit transactions where needed: If you need atomic (all-or-nothing) behavior for a group of statements in Snowflake, wrap them in BEGIN TRANSACTIONCOMMIT.

  • Se precisar de mais suporte, envie um e-mail para snowconvert-support@snowflake.com