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

EXPLODE_JSON_ARRAY_JSON_OUTER

説明

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

構文

EXPLODE_JSON_ARRAY_JSON_OUTER(<json>)

パラメータ

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

戻り値

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

  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_outer('[4, "abc", {"key": "value"}, 5.23, null]') t2 as c;
    +------+-----------------+
    | k1 | c |
    +------+-----------------+
    | 1 | 4 |
    | 1 | "abc" |
    | 1 | {"key":"value"} |
    | 1 | 5.23 |
    | 1 | NULL |
    +------+-----------------+
  3. 空の配列

    select * from example lateral view explode_json_array_json_outer('[]') t2 as c;
    +------+------+
    | k1 | c |
    +------+------+
    | 1 | NULL |
    +------+------+
  4. NULLパラメータ

    select * from example lateral view explode_json_array_json_outer(NULL) t2 as c;
    +------+------+
    | k1 | c |
    +------+------+
    | 1 | NULL |
    +------+------+
  5. 非配列パラメータ

    select * from example lateral view explode_json_array_json_outer('{}') t2 as c;
    +------+------+
    | k1 | c |
    +------+------+
    | 1 | NULL |
    +------+------+