FIELD
Updated at:
Retrieves the value of a member variable from a STRUCT object.
Command format
T field(struct <s>, string <fieldName>)Parameters
s: Required. A STRUCT object. The structure of the STRUCT is
{f1,T1, f2,T2[, ...]}.f1andf2are member variables.T1andT2are the values of the member variablesf1andf2, respectively.fieldName: Required. A STRING value that specifies the name of the member variable.
Return value
Returns the value of the specified member variable.
Example
-- Returns hello.
select field(named_struct('f1', 'hello', 'f2', 3), 'f1');Related functions
The FIELD function is a complex type function. For more functions that process complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.
Is this page helpful?