All Products
Search
Document Center

MaxCompute:FIELD

Last Updated:Jul 21, 2023

Obtains the value of a member variable in a struct.

Syntax

T field(struct <s>, string <fieldName>)

Parameters

  • s: required. This parameter specifies a struct. The struct is in the format of {f1:T1, f2:T2[, ...]}. f1 and f2 specify member variables, T1 specifies the value of f1, and T2 specifies the value of f2.

  • fieldName: required. The value is of the STRING type. This parameter specifies the member variable in the struct.

Return value

A value of the specific member variable in the struct is returned.

Examples

-- The return value is hello. 
select field(named_struct('f1', 'hello', 'f2', 3), 'f1');

Related functions

FIELD is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.