STRUCT
Description
The STRUCT
function is used to create a structured object that contains a specified number of fields, with each field consisting of its name and corresponding value. By using the STRUCT
function, multiple data values of different types can be combined into a single data type, i.e., a structured object.
Syntax
Parameters
- v1, v2, ..., vN: Any number of data values, which can be of different data types.
Return Results
Returns a structured object containing N fields, with field names defaulting to "col1", "col2", ..., "colN", and field values corresponding to the input parameters v1, v2, ..., vN.
Usage Example
- Create a structured object containing two fields, with field names "age" and "name", corresponding to age and name respectively:
Return Results:
- Combine different types of data (integer, string, boolean) into a structured object:
Return Results: