GET_PATH

functionsupportedCore SQL functions

docs.snowflake.com ↗

Semi-structured and structured data functions

Extracts a value from semi-structured data using a path name. GET_PATH is a variation of GET; it takes a VARIANT, OBJECT, or ARRAY column name as the first argument, and extracts the value of the field or the element according to the path name provided as the second argument.

Syntax

GET_PATH( <column_identifier> , '<path_name>' )

<column_identifier>:<path_name>

:( <column_identifier> , '<path_name>' )

Parameters

NameRequiredDescription
column_identifierrequiredAn expression that evaluates to a VARIANT, OBJECT, or ARRAY column.
path_namerequiredAn expression that evaluates to a VARCHAR value. This value specifies the path to the field or element that you want to extract. For structured types, you must specify a string constant.

Returns

- The returned value is the specified element of the ARRAY, or the value that corresponds to the specified key of a key-value pair in the OBJECT. - If the input object is a semi-structured OBJECT, ARRAY, or VARIANT value, the function returns a VARIANT value. The data type of the value is VARIANT because: In an ARRAY value, each element is of type VARIANT. - In an OBJECT value, the value in each key-value pair is of type VARIANT. - If the input object is a structured OBJECT, structured ARRAY, or MAP, the function returns a value of the type specified for the object. For example, if the type of the input object is ARRAY(NUMBER), the function returns a NUMBER value.

Usage notes

Referenced by