Macros

Translation reference to convert Teradata MACRO statement to Snowflake

Description

Teradata's MACRO statement is translated to Snowflake MACRO syntax.

For more information on Teradata MACRO, check here.

Some parts of the output code are omitted for clarity reasons.

Sample Source Patterns

Create Macro Transformation

Teradata

IN -> Teradata_01.sql
-- Additional Params: -t JavaScript
CREATE MACRO new_table (col1 INTEGER, col2 VARCHAR(12))
AS
(
	insert into table1 (col1, col2) values (:col1, :col2);
	select * from table1 where col1 = :col1;
);

Snowflake

OUT -> Teradata_01.sql
CREATE OR REPLACE PROCEDURE new_table (COL1 FLOAT, COL2 VARCHAR(12))
RETURNS STRING
LANGUAGE JAVASCRIPT
COMMENT = '{"origin":"sf_sc","name":"snowconvert","version":{"major":1, "minor":0},{"attributes":{"component":"teradata"}}'
EXECUTE AS CALLER
AS
$$
    // SnowConvert Helpers Code section is omitted.
    
    // ** SSC-EWI-0022 - ONE OR MORE IDENTIFIERS IN THIS STATEMENT WERE CONSIDERED PARAMETERS BY DEFAULT. REFERENCED TABLE NOT FOUND. **
    EXEC(`INSERT INTO table1 (col1, col2)
    VALUES (:1, :2)`,[COL1,COL2]);
    INSERT_TEMP(`SELECT * from table1 where col1 = :1`,[COL1]);
    return tablelist;
$$;

Known Issues

1. Macro transform to store procedure

The Teradata Macro is transformed to a stored procedure since Snowflake does not support Macros.

  1. SSC-EWI-0022: One or more identifiers in this statement were considered parameters by default.

Last updated