Built-in functions

For more information about built-in functions and their Snowflake equivalents, also see Common built-in functions.

Aggregate Functions

Aggregate functions compute a single result value from a set of input values. (Redshift SQL Language Reference Aggregate Functions).

Redshift
Snowflake

ANY_VALUE ( [ DISTINCT | ALL ] expression )

ANY_VALUE ( [ DISTINCT ]expression )

Notes: Snowflake supports the grammar, though ALL is disallowed. DISTINCT has no effect in either.

AVG ( [ DISTINCT | ALL ] expression )

AVG ( [ DISTINCT ] expression)

Notes: Redshift and Snowflake may show different precision/decimals due to data type rounding/formatting.

LISTAGG

Notes: Redshift's DISTINCT ignores trailing spaces ('a ' = 'a'); Snowflake's does not. (See SSC-FDM-PG0013).

MEDIAN

Notes: Snowflake does not allow the use of date types, while Redshift does. (See SSC-FDM-PG0013).

STDDEV/STDDEV_SAMP ( [ DISTINCT | ALL ] expression)

STDDEV_POP ( [ DISTINCT | ALL ] expression)

STDDEV/STDDEV_SAMP ( [ DISTINCT ] expression)

STDDEV_POP ( [ DISTINCT ] expression)

Notes: Snowflake supports all the grammar, though ALL is disallowed.

VARIANCE/VAR_SAMP ( [ DISTINCT | ALL ] expression)

VAR_POP ( [ DISTINCT | ALL ] expression)

VARIANCE/VAR_SAMP ( [ DISTINCT ] expression)

VAR_POP ( [ DISTINCT ] expression)

Notes: Snowflake supports all the grammar, though ALL is disallowed.

Array Functions

Creates an array of the SUPER data type. (Redshift SQL Language Reference Array Functions).

Redshift
Snowflake

ARRAY ( [ expr1 ] [ , expr2 [ , ... ] ] )

ARRAY_CONSTRUCT

( [ <expr1> ] [ , <expr2> [ , ... ] ] )

ARRAY_CONCAT ( super_expr1, super_expr2 )

ARRAY_CAT ( <array1> , <array2> )

ARRAY_FLATTEN

( super_expr1,super_expr2,.. )

ARRAY_FLATTEN ( <array> )

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

GET_ARRAY_LENGTH ( super_expr )

ARRAY_SIZE ( <array> | <variant>)

SPLIT_TO_ARRAY ( string,delimiter )

SPLIT (<string>, <separator>)

Notes: Redshift allows missing delimiters; Snowflake requires them, defaulting to comma

SUBARRAY ( super_expr, start_position, length )

ARRAY_SLICE ( <array> , <from> , <to> )

Notes: Function names and the second argument differ; adjust arguments for equivalence.

Conditional expressions

Redshift
Snowflake

DECODE

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

COALESCE ( expression, expression, ... )

COALESCE ( expression, expression, ... )

GREATEST ( value [, ...] )

GREATEST_IGNORE_NULLS ( <expr1> [, <expr2> ... ] )

LEAST ( value [, ...] )

LEAST_IGNORE_NULLS ( <expr1> [, <expr2> ... ])

NVL( expression, expression, ... )

NVL ( expression, expression )

Notes: Redshift's NVL accepts multiple arguments; Snowflake's NVL accepts only two. To match Redshift behavior, NVL with more than two arguments is converted to COALESCE.

NULLIF

Notes: Redshift's NULLIF ignores trailing spaces in some string comparisons, unlike Snowflake. Therefore, the transformation adds RTRIM for equivalence.

Data type formatting functions

Data type formatting functions provide an easy way to convert values from one data type to another. For each of these functions, the first argument is always the value to be formatted and the second argument contains the template for the new format. (Redshift SQL Language Reference Data type formatting functions).

Redshift
Snowflake

TO_CHAR

Notes: Snowflake's support for this function is partial (see SSC-EWI-PG0005).

TO_DATE

Notes: Snowflake's TO_DATE fails on invalid dates like '20010631' (June has 30 days), unlike Redshift's lenient TO_DATE. Use TRY_TO_DATE in Snowflake to handle these cases by returning NULL. (see SSC-FDM-RS0004, SSC-EWI-PG0005, SSC-FDM-0032).

Date and time functions

Redshift
Snowflake

ADD_MONTHS

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

CONVERT_TIMEZONE ( <source_tz> , <target_tz> , <source_timestamp_ntz> )

CONVERT_TIMEZONE ( <target_tz> , <source_timestamp> )

Notes: Redshift defaults to UTC; the Snowflake function requires explicit UTC specification. Therefore, it will be added as the target timezone.

DATEADD/DATE_ADD ( datepart, interval, {date | time | timetz | timestamp} )

DATE_ADD ( <date_or_time_part>, <value>, <date_or_time_expr> )

Notes: Invalid date part formats are translated to Snowflake-compatible formats.

DATEDIFF

Notes: Invalid date part formats are translated to Snowflake-compatible formats.

DATE_PART

Notes: this function is partially supported by Snowflake. (See SSC-EWI-PGOOO5).

YEAR ( <date_or_timestamp_expr> )

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

DATE_TRUNC

Notes: Invalid date part formats are translated to Snowflake-compatible formats.

LAST_DAY

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

NEXT_DAY

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

EXTRACT Notes: Part-time or Date time supported: DAY, DOW, DOY, EPOCH, HOUR, MINUTE, MONTH, QUARTER, SECOND, WEEK, YEAR.

Redshift timestamps default to microsecond precision (6 digits); Snowflake defaults to nanosecond precision (9 digits). Adjust precision as needed using ALTER SESSION (e.g., ALTER SESSION SET TIMESTAMP_OUTPUT_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF2';). Precision loss may occur depending on the data type used. Since some formats are incompatible with Snowflake, adjusting the account parameters DATE_INPUT_FORMAT or TIME_INPUT_FORMAT might maintain functional equivalence between platforms.

Hash Functions

A hash function is a mathematical function that converts a numerical input value into another value. (Redshift SQL Language Reference Hash functions).

Redshift
Snowflake

FNV_HASH (value [, seed])

HASH ( <expr> [ , <expr> ... ] | *)

Notes: In Redshift's FNV_HASH function, the seed parameter is optional, but it is not used in the Snowflake's Hash function since the seed parameter is only used on FNV algorithm.

JSON Functions

Redshift
Snowflake

JSON_EXTRACT_PATH_TEXT

Notes:

  1. Redshift treats newline, tab, and carriage return characters literally; Snowflake interprets them.

  2. A JSON literal and dot-separated path are required to access nested objects in the Snowflake function.

  3. Paths with spaces in variables must be quoted.

Math functions

Redshift and Snowflake results may differ in scale.

String functions

String functions process and manipulate character strings or expressions that evaluate to character strings. (Redshift SQL Language Reference String functions).

Redshift
Snowflake

LEFT/RIGHT

Notes: For negative lengths in LEFT/RIGHT, Snowflake returns an empty string; Redshift raises an error.

OCTET_LENGTH

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

QUOTE_IDENT (string)

CONCAT ('"', string, '"')

REGEXP_REPLACE

Notes: This function includes a parameters argument that enables the user to interpret the pattern using the Perl Compatible Regular Expression (PCRE) dialect, represented by the p value, this is removed to avoid any issues. (See SSC-EWI-0009, SC-FDM-0032, SSC-FDM- PG0011).

SOUNDEX

Notes: Certain special characters, the results may vary between platforms (See SSC-FDM-PG0013).

SPLIT_PART

Notes: Snowflake and Redshift handle SPLIT_PART differently with case-insensitive collations.

STRPOS (string, substring )

POSITION ( <expr1> IN <expr> )

SUBSTRING

Notes: Snowflake partially supports this function. Redshift's SUBSTRING, with a non-positive start_position, calculates start_position + number_characters (returning '' if the result is non-positive). Snowflake's behavior differs. (See SSC-EWI-RS0006).

TRIM

Notes: Redshift uses keywords (BOTH, LEADING, TRAILING) for trim; Snowflake uses TRIM, LTRIM, RTRIM.

SUPER type information functions

Redshift
Snowflake

IS_ARRAY

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

IS_BOOLEAN

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

Window functions

Redshift
Snowflake

AVG

Notes: AVG rounding/formatting can vary by data type between Redshift and Snowflake.

DENSE_RANK

Notes: ORDER BY is mandatory in Snowflake; missing clauses are replaced with ORDER BY 1.

FIRST_VALUE

Notes: Snowflake needs ORDER BY; missing clauses get ORDER BY <expr>.

LAST_VALUE

Notes: Snowflake needs ORDER BY; missing clauses get ORDER BY <expr>.

LEAD

Notes: Redshift allows constant or expression offsets; Snowflake allows only constant offsets.

LISTAGG

Notes: Redshift's DISTINCT ignores trailing spaces ('a ' = 'a'); Snowflake's does not. (See SSC-FDM-PG0013).

MEDIAN

Notes: Snowflake does not allow the use of date types, while Redshift does. (See SSC-FDM-PG0013).

NTH_VALUE

Notes: ORDER BY is mandatory in Snowflake; missing clauses are replaced with ORDER BY 1.

NTILE

Notes: ORDER BY is mandatory in Snowflake; missing clauses are replaced with ORDER BY 1. (See SSC-FDM-PG0013).

PERCENT_RANK

Notes: ORDER BY is mandatory in Snowflake; missing clauses are replaced with ORDER BY 1.

PERCENTILE_CONT

Notes: Rounding varies between platforms.

RATIO_TO_REPORT

Notes: the results may vary between platforms (See SSC-FDM-PG0013).

ROW_NUMBER

Notes: ORDER BY is mandatory in Snowflake; missing clauses are replaced with ORDER BY 1.

STDDEV_SAMP | STDDEV | STDDEV_POP

( [ ALL ] expression )

OVER ( [ PARTITION BY expr_list ]

[ ORDER BY order_list frame_clause ] )

STDDEV/STDDEV_SAMP /STDDEV_POP

( [ DISTINCT ] expr1) OVER ( [ PARTITION BY expr2 ] [ ORDER BY expr3 [ ASC | DESC ] [ <window_frame> ] ] )

Notes: Snowflake supports all the grammar, though ALL is disallowed.

VAR_SAMP | VARIANCE | VAR_POP

( [ ALL ] expression )

OVER ( [ PARTITION BY expr_list ]

[ ORDER BY order_list frame_clause ] )

VARIANCE/VAR_SAMP / VAR_POP

( [ DISTINCT ] expr1) OVER ( [ PARTITION BY expr2 ] [ ORDER BY expr3 [ ASC | DESC ] [ <window_frame> ] ] )

Notes: Snowflake supports all the grammar, though ALL is disallowed.

Known Issues

  1. For more information about quoted identifiers in functions, click here.

  • SSC-EWI-PG0005: Date or time format is not supported in Snowflake.

  • SSC-FDM-0032: Parameter is not a literal value, transformation could not be fully applied

  • SSC-FDM-PG0013: Function syntactically supported by Snowflake but may have functional differences.

  • SSC-FDM-RS0004: Invalid dates will cause errors in Snowflake.

Last updated