メインコンテンツまでスキップ
バージョン: 26.x

EXPLODE_JSON_ARRAY_JSON

説明

explode_json_array_json Table関数はJSON配列を受け取ります。実装ロジックは、JSON配列をarray型に変換してから処理のためにexplode関数を呼び出すことです。動作は次と同等です:explode(cast(<json_array> as Array<JSON>))。 これはLATERAL VIEWと組み合わせて使用する必要があります。

構文

EXPLODE_JSON_ARRAY_JSON(<json>)

パラメータ

  • <json> JSON型、内容は配列である必要があります。

戻り値

  • <json>内のすべての要素から構成される単一列、複数行の結果を返します。列の型はNullable<JSON>です。
  • <json>がNULLまたは空の配列(要素数が0)の場合、0行が返されます。

  1. データを準備する

    create table example(
    k1 int
    ) properties(
    "replication_num" = "1"
    );

    insert into example values(1);
  2. 通常パラメータ

    select * from example lateral view explode_json_array_json('[4, "abc", {"key": "value"}, 5.23, null]') t2 as c;
    +------+-----------------+
    | k1 | c |
    +------+-----------------+
    | 1 | 4 |
    | 1 | NULL |
    | 1 | {"key":"value"} |
    | 1 | 5.23 |
    | 1 | NULL |
    +------+-----------------+
  3. 空の配列

    select * from example lateral view explode_json_array_json('[]') t2 as c;
    Empty set (0.03 sec)
  4. NULLパラメータ

    select * from example lateral view explode_json_array_json(NULL) t2 as c;
    Empty set (0.03 sec)
  5. 非配列パラメータ

    select * from example lateral view explode_json_array_json('{}') t2 as c;
    Empty set (0.03 sec)