dataengref migrate

Home / Teradata

Teradata NULLIFZERO in Snowflake, Databricks and BigQuery

Snowflake keeps NULLIFZERO and Databricks Runtime 16.0 added it. BigQuery uses NULLIF(x, 0), which also works everywhere else.

Teradata function: NULLIFZERO(arg) · Teradata docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeSame nameNULLIFZERO(expr)Returns NULL if the argument is 0.Snowflake docs
DatabricksSame namenullifzero(expr)Databricks Runtime 16.0 and above; the docs do not list it for Databricks SQL warehouses.Databricks docs
BigQueryRewriteNULLIF(expr, 0)Standard SQL.BigQuery docs

Behavior differences to check

Examples

Conversion rate without dividing by zero

Teradata
SELECT orders / NULLIFZERO(visits) AS conversion FROM daily_stats;
Snowflake
SELECT orders / NULLIFZERO(visits) AS conversion FROM daily_stats;
Databricks
SELECT orders / nullif(visits, 0) AS conversion FROM daily_stats;
BigQuery
SELECT SAFE_DIVIDE(orders, visits) AS conversion FROM daily_stats;

Other Teradata functions

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.