All Products
Search
Document Center

MaxCompute:FIELD

Last Updated:Mar 26, 2026

Retrieves the value of a member variable from a struct.

Syntax

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

Parameters

ParameterRequiredTypeDescription
sYesSTRUCTThe struct to retrieve from. Format: {f1:T1, f2:T2[, ...]}, where f1 and f2 are member variable names, T1 is the value of f1, and T2 is the value of f2.
fieldNameYesSTRINGThe name of the member variable to retrieve.

Return value

Returns the value of the specified member variable. The return type T matches the type of that member variable.

Examples

-- Returns: hello
SELECT field(named_struct('f1', 'hello', 'f2', 3), 'f1');

Related functions

FIELD is a complex type function. For functions that process ARRAY, MAP, STRUCT, and JSON data, see Complex type functions.