STRUCT
描述
根据给定的值构造并返回 struct ,参数可以是多列或常量
语法
STRUCT( <expr1> [ , <expr2> ... ] )
参数
参数 | 说明 |
---|---|
<expr> | 构造 struct 的输入内容 |
返回值
根据给定的值构造并返回 struct ,参数可以是多列或常量
举例
select struct(1, 'a', "abc"),struct(null, 1, null),struct(cast('2023-03-16' as datetime));
+--------------------------------------+--------------------------------------+---------------------------------------------+
| struct(1, 'a', 'abc') | struct(NULL, 1, NULL) | struct(cast('2023-03-16' as DATETIMEV2(0))) |
+--------------------------------------+--------------------------------------+---------------------------------------------+
| {"col1":1, "col2":"a", "col3":"abc"} | {"col1":null, "col2":1, "col3":null} | {"col1":"2023-03-16 00:00:00"} |
+--------------------------------------+--------------------------------------+---------------------------------------------+