dataengref migrate

Home / Teradata

Teradata ZEROIFNULL in Snowflake, Databricks and BigQuery

Snowflake keeps ZEROIFNULL, and Databricks Runtime 16.0 added it too. BigQuery has no such function; use IFNULL(x, 0) or COALESCE(x, 0).

Teradata function: ZEROIFNULL(arg) · Teradata docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeSame nameZEROIFNULL(expr)Returns 0 if the argument is NULL, otherwise the argument.Snowflake docs
DatabricksSame namezeroifnull(expr)Databricks Runtime 16.0 and above; the docs do not list it for Databricks SQL warehouses, where coalesce(expr, 0) works everywhere.Databricks docs
BigQueryRewriteIFNULL(expr, 0)COALESCE(expr, 0) is equivalent.BigQuery docs

Behavior differences to check

Databricks

Examples

Treat missing sales as zero

Teradata
SELECT store_id, ZEROIFNULL(sales) AS sales FROM daily_sales;
Snowflake
SELECT store_id, ZEROIFNULL(sales) AS sales FROM daily_sales;
Databricks
SELECT store_id, zeroifnull(sales) AS sales FROM daily_sales;
BigQuery
SELECT store_id, IFNULL(sales, 0) AS sales FROM daily_sales;

Other Teradata functions

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