dataengref migrate

Home / Teradata

Teradata to Snowflake: function mapping

2 of 5 common Teradata functions need a change in Snowflake. Mapping table with Snowflake syntax and behavior differences.

Other targets: Teradata to Databricks · Teradata to BigQuery

Needs a rewrite (1)

No Snowflake function with the same behavior; use the construct shown.

TeradataSnowflakeNotes
SAMPLERewrite SAMPLE (n ROWS) / SAMPLE (percent)The number without ROWS is a percentage, not a fraction.
Teradata SAMPLE 0.25 means 25 percent. Snowflake SAMPLE (0.25) means 0.25 percent, a hundred times smaller.
Multiple samples with SAMPLEID and stratified sampling (WHEN ... THEN) have no direct equivalent; build them with a window function over RANDOM().

Different name (1)

Same behavior under another name; rename the call and check the notes.

TeradataSnowflakeNotes
OREPLACEDifferent name REPLACE(subject, pattern [, replacement])The replacement defaults to an empty string.
OREPLACE(s, 'x', NULL) removes 'x' in Teradata; REPLACE(s, 'x', NULL) returns NULL in the targets. Pass '' explicitly.

Works as written (3)

The same call runs, but check the notes for behavior differences.

TeradataSnowflakeNotes
NULLIFZEROSame name NULLIFZERO(expr)Returns NULL if the argument is 0.
NULLIFZERO is mostly used to avoid division by zero. BigQuery also offers SAFE_DIVIDE(x, y), which returns NULL when y is 0.
QUALIFYSame name QUALIFY <predicate>Evaluated after window functions.
Teradata accepts legacy ordered-analytic syntax such as QUALIFY RANK(amount DESC) <= 3 and CSUM. Rewrite these as RANK() OVER (ORDER BY amount DESC) and SUM(...) OVER (...).
ZEROIFNULLSame name ZEROIFNULL(expr)Returns 0 if the argument is NULL, otherwise the argument.

Paste a query into the SQL checker to list the functions it uses that need a change.