dataengref migrate

Home / Redshift

Redshift SPLIT_PART in Snowflake, Databricks and BigQuery

Snowflake and Databricks keep SPLIT_PART with the same arguments, and both also accept negative positions counted from the end. BigQuery has no SPLIT_PART; index the array from SPLIT() with SAFE_OFFSET.

Redshift function: SPLIT_PART(string, delimiter, position) · Redshift docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeSame nameSPLIT_PART(string, delimiter, partNumber)Negative numbers count from the end; out-of-range positions return an empty string.Snowflake docs
DatabricksSame namesplit_part(str, delim, partNum)Databricks SQL and Databricks Runtime 11.3 LTS and above; negative numbers count from the end, out of range returns an empty string.Databricks docs
BigQueryRewriteSPLIT(value, delimiter)[SAFE_OFFSET(n - 1)]Zero-based offset; out-of-range positions return NULL rather than an empty string.BigQuery docs

Behavior differences to check

BigQuery

Examples

Domain from an email address

Redshift
SELECT SPLIT_PART(email, '@', 2) AS domain FROM users;
Snowflake
SELECT SPLIT_PART(email, '@', 2) AS domain FROM users;
Databricks
SELECT split_part(email, '@', 2) AS domain FROM users;
BigQuery
SELECT SPLIT(email, '@')[SAFE_OFFSET(1)] AS domain FROM users;

Other Redshift functions

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