Expands a given struct array. Each array element corresponds to a row and each struct element corresponds to a column in each row.
Syntax
inline(array<struct<f1:T1, f2:T2[, ...]>>)
Parameters
f1:T1 and f2:T2: required. All data types are supported. f1
and f2
specify member variables, T1
specifies the value of f1
, and T2
specifies the value of f2
.
Return value
The expanded data of the struct array is returned.
Examples
The t_table
table contains the t_struct (STRUCT<user_id:BIGINT,user_name:STRING,married:STRING,weight:DOUBLE>)
field. Data in the table:
+----------+
| t_struct |
+----------+
| {user_id:10001, user_name:LiLei, married:N, weight:63.5} |
| {user_id:10002, user_name:HanMeiMei, married:Y, weight:43.5} |
+----------+
Sample statement:
-- Expand the t_struct column.
select inline(array(t_struct)) from t_table;
-- The following result is returned:
+------------+-----------+---------+------------+
| user_id | user_name | married | weight |
+------------+-----------+---------+------------+
| 10001 | LiLei | N | 63.5 |
| 10002 | HanMeiMei | Y | 43.5 |
+------------+-----------+---------+------------+
Related functions
INLINE 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.