メインコンテンツまでスキップ

STRUCT

説明

可変要素でstructを構築して返します。Tnは列またはリテラルが可能です

構文

STRUCT( <expr1> [ , <expr2> ... ] )

パラメータ

パラメータ説明
<expr>structの入力コンテンツを構築する

戻り値

可変個の要素でstructを構築して返します。Tnはカラムまたはリテラルになります

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"} |
+--------------------------------------+--------------------------------------+---------------------------------------------+