Built-in functions

circle-info

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentationarrow-up-right

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected]envelope.

Thank you for your understanding.

circle-info

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 Functionsarrow-up-right).

Redshift
Snowflake

ALL ] expression )

AVGarrow-up-right ( [ DISTINCT | ALL ] expression )

AVGarrow-up-right ( [ DISTINCT ] expression)

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

LISTAGGarrow-up-right

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

MEDIANarrow-up-right

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

ALL ] expression)

STDDEV_POParrow-up-right ( [ DISTINCT

ALL ] expression)

VAR_POParrow-up-right ( [ DISTINCT

Array Functions

Creates an array of the SUPER data type. (Redshift SQL Language Reference Array Functionsarrow-up-right).

Redshift
Snowflake

ARRAYarrow-up-right ( [ expr1 ] [ , expr2 [ , ... ] ] )

ARRAY_CONSTRUCTarrow-up-right

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

ARRAY_CONCATarrow-up-right ( super_expr1, super_expr2 )

ARRAY_CATarrow-up-right ( <array1> , <array2> )

ARRAY_FLATTENarrow-up-right

( super_expr1,super_expr2,.. )

ARRAY_FLATTENarrow-up-right ( <array> )

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

ARRAY_SIZEarrow-up-right ( <array> | <variant>)

SPLIT_TO_ARRAYarrow-up-right ( string,delimiter )

SPLITarrow-up-right (<string>, <separator>)

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

SUBARRAYarrow-up-right ( super_expr, start_position, length )

ARRAY_SLICEarrow-up-right ( <array> , <from> , <to> )

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

Conditional expressions

Redshift
Snowflake

DECODEarrow-up-right

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

COALESCEarrow-up-right ( expression, expression, ... )

COALESCEarrow-up-right ( expression, expression, ... )

GREATESTarrow-up-right ( value [, ...] )

GREATEST_IGNORE_NULLSarrow-up-right ( <expr1> [, <expr2> ... ] )

LEASTarrow-up-right ( value [, ...] )

LEAST_IGNORE_NULLSarrow-up-right ( <expr1> [, <expr2> ... ])

NVLarrow-up-right( expression, expression, ... )

NVLarrow-up-right ( 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.

NULLIFarrow-up-right

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 functionsarrow-up-right).

Redshift
Snowflake

TO_CHARarrow-up-right

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

TO_DATEarrow-up-right

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-PG0005arrow-up-right, SSC-FDM-0032).

Date and time functions

Redshift
Snowflake

ADD_MONTHSarrow-up-right

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

CONVERT_TIMEZONEarrow-up-right ( <source_tz> , <target_tz> , <source_timestamp_ntz> )

CONVERT_TIMEZONEarrow-up-right ( <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_ADDarrow-up-right ( datepart, interval, {date | time | timetz | timestamp} )

DATE_ADDarrow-up-right ( <date_or_time_part>, <value>, <date_or_time_expr> )

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

DATEDIFFarrow-up-right

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

DATE_PARTarrow-up-right

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

YEARarrow-up-right ( <date_or_timestamp_expr> )

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

DATE_TRUNCarrow-up-right

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

LAST_DAYarrow-up-right

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

NEXT_DAYarrow-up-right

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

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

circle-info

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_FORMATarrow-up-right 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 functionsarrow-up-right).

Redshift
Snowflake

FNV_HASHarrow-up-right (value [, seed])

HASHarrow-up-right ( <expr> [ , <expr> ... ]

JSON Functions

Redshift
Snowflake

JSON_EXTRACT_PATH_TEXTarrow-up-right

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

circle-info

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 functionsarrow-up-right).

Redshift
Snowflake

LEFTarrow-up-right/RIGHTarrow-up-right

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

OCTET_LENGTHarrow-up-right

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

REGEXP_REPLACEarrow-up-right

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-0009arrow-up-right, SC-FDM-0032, SSC-FDM- PG0011).

SOUNDEXarrow-up-right

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

SPLIT_PARTarrow-up-right

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

STRPOSarrow-up-right (string, substring )

POSITIONarrow-up-right ( <expr1> IN <expr> )

SUBSTRINGarrow-up-right

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).

TRIMarrow-up-right

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

SUPER type information functions

Redshift
Snowflake

IS_ARRAYarrow-up-right

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

IS_BOOLEANarrow-up-right

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

Window functions

Redshift
Snowflake

AVGarrow-up-right

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

DENSE_RANKarrow-up-right

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

FIRST_VALUEarrow-up-right

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

LAST_VALUEarrow-up-right

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

LEADarrow-up-right

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

LISTAGGarrow-up-right

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

MEDIANarrow-up-right

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

NTH_VALUEarrow-up-right

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

NTILEarrow-up-right

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

PERCENT_RANKarrow-up-right

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

PERCENTILE_CONTarrow-up-right

Notes: Rounding varies between platforms.

RATIO_TO_REPORTarrow-up-right

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

ROW_NUMBERarrow-up-right

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

Known Issues

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

Last updated