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

EXPLODE_JSON_ARRAY_DOUBLE_OUTER

説明

explode_json_array_double_outerTable関数は JSON 配列を受け取ります。その実装ロジックは、JSON 配列を配列型に変換してから処理のためにexplode_outer関数を呼び出すことです。この動作はexplode_outer(cast(<json_array> as Array<DOUBLE>))と同等です。 これはLATERAL VIEWと一緒に使用する必要があります。

構文

EXPLODE_JSON_ARRAY_DOUBLE_OUTER(<json>)

パラメータ

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

戻り値

  • <json>内のすべての要素で構成される単一列、複数行の結果を返します。列の型はNullable<DOUBLE>です。
  • <json>がNULLまたは空の配列(要素数が0)の場合、NULLを含む1行が返されます。
  • JSON配列内の要素がDOUBLE型でない場合、関数はそれらをDOUBLEに変換しようとします。DOUBLEに変換できない要素はNULLに変換されます。型変換ルールについては、JSON タイプ Conversionを参照してください。

  1. データを準備

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

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

    select * from example lateral view explode_json_array_double_outer('[4, 5, 5.23, null]') t2 as c;
    +------+------+
    | k1 | c |
    +------+------+
    | 1 | 4 |
    | 1 | 5 |
    | 1 | 5.23 |
    | 1 | NULL |
    +------+------+
  3. DOUBLE型

    select * from example 
    lateral view
    explode_json_array_double_outer('[123.445, 9223372036854775807.0, 9223372036854775808.0, -9223372036854775808.0, -9223372036854775809.0]') t2 as c;
    +------+------------------------+
    | k1 | c |
    +------+------------------------+
    | 1 | 123.445 |
    | 1 | 9.223372036854776e+18 |
    | 1 | 9.223372036854776e+18 |
    | 1 | -9.223372036854776e+18 |
    | 1 | -9.223372036854776e+18 |
    +------+------------------------+
  4. 空の配列

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

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

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