dataengref migrate

Home / Teradata

Teradata to BigQuery: function mapping

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

Other targets: Teradata to Snowflake · Teradata to Databricks

Needs a rewrite (3)

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

TeradataBigQueryNotes
NULLIFZERORewrite NULLIF(expr, 0)Standard SQL.
NULLIFZERO is mostly used to avoid division by zero. BigQuery also offers SAFE_DIVIDE(x, y), which returns NULL when y is 0.
SAMPLERewrite TABLESAMPLE SYSTEM (percent PERCENT)Samples blocks, not rows. For an exact row count use ORDER BY RAND() LIMIT n.
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().
ZEROIFNULLRewrite IFNULL(expr, 0)COALESCE(expr, 0) is equivalent.

Different name (1)

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

TeradataBigQueryNotes
OREPLACEDifferent name REPLACE(original_value, from_pattern, to_pattern)All three arguments are required.
OREPLACE(s, 'x', NULL) removes 'x' in Teradata; REPLACE(s, 'x', NULL) returns NULL in the targets. Pass '' explicitly.
The two-argument form OREPLACE(s, 'x') must become REPLACE(s, 'x', '').

Works as written (1)

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

TeradataBigQueryNotes
QUALIFYSame name QUALIFY bool_expressionA window function must appear in the QUALIFY clause or the SELECT list.
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 (...).

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