Files
greptimedb/tests/cases/standalone/common/function/json/json_get.result
T
discord9andNing Sun 94d7e2c7fc feat!: upgrade DataFusion to 55 (#8555)
* feat!: upgrade DataFusion dependencies to 55

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* refactor: migrate DataFusion 55 APIs

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: preserve table function planning behavior

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: preserve PostgreSQL query compatibility

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: preserve distributed execution plan behavior

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: cover DataFusion 55 behavior regressions

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: update DataFusion 55 SQLness expectations

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: complete DataFusion 55 test API migration

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: address DataFusion 55 CI regressions

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: address remaining DataFusion 55 regressions

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: adapt latest base code to DataFusion 55

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: normalize environment-specific DataFusion 55 plans

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: align final DataFusion 55 expectations

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: isolate DataFusion 55 regression cases

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: preserve empty result schema in timestamp widening

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: preserve JSON source column order

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* chore: use released DataFusion 55 integrations

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: adapt latest execution plan mock to DataFusion 55

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: pin DataFusion recursive schema and date repairs

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix(promql): align dictionary temporality match keys

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: retain Greptime DataFusion fork behaviors on version 55

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: restore ordinary function error expectations

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: refresh distributed count compatibility plan

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix(query): adapt last-row cast hint to DataFusion 55

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: refresh instant last-row empty results for Arrow 59

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* style: simplify DataFusion expression visitor imports

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: restore sorting and PostgreSQL column-order assertions

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix(function): restore primitive numeric coercion signatures

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* refactor(function): share geo integer signature types

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: cover timestamp widening overflow boundaries

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: fix decimal coercion regression imports

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix(function): preserve scalar count_hash NULL state semantics

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: simplify decimal clamp case type inference

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: retain historical count_hash wrapper result

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: restore timestamp widening equality and IN pruning

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: carry upstream aggregate dynamic filter correctness fix

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: carry upstream null and predicate simplification fixes

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: restore baseline JSON ordering expectations

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: restore histogram JSON ordering expectations

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: refresh empty PromQL range result schemas

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: align native timestamp plan with DF55 decimal display

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: refresh native timestamp SQLness results for DF55

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: regenerate NULL sample empty result headers for DF55

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: use DF55 child replacement API in timestamp regressions

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: expose pushed scan dynamic filters to DF55 producers

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: encode string-backed PostgreSQL OID aliases in binary results

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: verify REGPROC binary and text over PostgreSQL protocol

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: register real PostgreSQL catalogs in server fixtures

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: complete DF55 expression inventories for custom query plans

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: correct RangeSelect expression fixture and column identities

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* ci: wait for Kafka WAL helper deployment rollout

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* test: update custom storage empty result headers

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: require exact row counts in scan statistics

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

* fix: suppress deprecated partition_statistics warning in test

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>

---------

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>
Co-authored-by: Ning Sun <sunng@protonmail.com>
2026-09-15 11:42:38 +00:00

462 lines
18 KiB
Plaintext

-- json_get functions --
SELECT json_get_int(parse_json('{"a": {"b": {"c": 1}}}'), 'a.b.c');
+------------------------------------------------------------------------+
| json_get_int(parse_json(Utf8("{"a": {"b": {"c": 1}}}")),Utf8("a.b.c")) |
+------------------------------------------------------------------------+
| 1 |
+------------------------------------------------------------------------+
SELECT json_get_float(parse_json('{"a": {"b": {"c": 1.234}}}'), 'a:b.c');
+------------------------------------------------------------------------------+
| json_get_float(parse_json(Utf8("{"a": {"b": {"c": 1.234}}}")),Utf8("a:b.c")) |
+------------------------------------------------------------------------------+
| 1.234 |
+------------------------------------------------------------------------------+
SELECT json_get_string(parse_json('{"a": {"b": {"c": "foo"}}}'), 'a.b:c');
+-------------------------------------------------------------------------------+
| json_get_string(parse_json(Utf8("{"a": {"b": {"c": "foo"}}}")),Utf8("a.b:c")) |
+-------------------------------------------------------------------------------+
| foo |
+-------------------------------------------------------------------------------+
SELECT json_get_bool(parse_json('{"a": {"b": {"c": true}}}'), 'a.b["c"]');
+-------------------------------------------------------------------------------+
| json_get_bool(parse_json(Utf8("{"a": {"b": {"c": true}}}")),Utf8("a.b["c"]")) |
+-------------------------------------------------------------------------------+
| true |
+-------------------------------------------------------------------------------+
SELECT json_get_int(parse_json('{"a": {"b": {"c": {"d": 1}}}}'), 'a.b');
+-----------------------------------------------------------------------------+
| json_get_int(parse_json(Utf8("{"a": {"b": {"c": {"d": 1}}}}")),Utf8("a.b")) |
+-----------------------------------------------------------------------------+
| |
+-----------------------------------------------------------------------------+
SELECT json_get_string(parse_json('{"a": {"b": {"c": {"d": 1}}}}'), 'a.b');
+--------------------------------------------------------------------------------+
| json_get_string(parse_json(Utf8("{"a": {"b": {"c": {"d": 1}}}}")),Utf8("a.b")) |
+--------------------------------------------------------------------------------+
| |
+--------------------------------------------------------------------------------+
SELECT json_to_string(json_get_object(parse_json('{"a": {"b": {"c": {"d": 42}}}}'), 'a.b.c'));
+---------------------------------------------------------------------------------------------------+
| json_to_string(json_get_object(parse_json(Utf8("{"a": {"b": {"c": {"d": 42}}}}")),Utf8("a.b.c"))) |
+---------------------------------------------------------------------------------------------------+
| {"d":42} |
+---------------------------------------------------------------------------------------------------+
SELECT json_get_int(json_get_object(parse_json('{"a": {"b": {"c": {"d": 42}}}}'), 'a.b.c'), 'd');
+-----------------------------------------------------------------------------------------------------------+
| json_get_int(json_get_object(parse_json(Utf8("{"a": {"b": {"c": {"d": 42}}}}")),Utf8("a.b.c")),Utf8("d")) |
+-----------------------------------------------------------------------------------------------------------+
| 42 |
+-----------------------------------------------------------------------------------------------------------+
SELECT json_get_object(parse_json('{"a": {"b": {"c": {"d": 42}}}}'), 'a.e');
+---------------------------------------------------------------------------------+
| json_get_object(parse_json(Utf8("{"a": {"b": {"c": {"d": 42}}}}")),Utf8("a.e")) |
+---------------------------------------------------------------------------------+
| |
+---------------------------------------------------------------------------------+
-- test functions with table rows --
CREATE TABLE jsons(j JSON, ts timestamp time index);
Affected Rows: 0
INSERT INTO jsons VALUES(parse_json('{"a": {"b": {"c": 1}}}'), 1);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('{"a": {"b": {"c": 1.234}}}'), 2);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('{"a": {"b": {"c": "foo"}}}'), 3);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('{"a": {"b": {"c": true}}}'), 4);
Affected Rows: 1
SELECT json_get_int(j, 'a.b.c') FROM jsons;
+-------------------------------------+
| json_get_int(jsons.j,Utf8("a.b.c")) |
+-------------------------------------+
| 1 |
| |
| |
| 1 |
+-------------------------------------+
SELECT json_get_float(j, 'a["b"].c') FROM jsons;
+------------------------------------------+
| json_get_float(jsons.j,Utf8("a["b"].c")) |
+------------------------------------------+
| 1.0 |
| 1.234 |
| |
| 1.0 |
+------------------------------------------+
SELECT json_get_string(j, 'a.b.c?(@ == 1)') FROM jsons;
+-------------------------------------------------+
| json_get_string(jsons.j,Utf8("a.b.c?(@ == 1)")) |
+-------------------------------------------------+
| 1 |
| |
| |
| |
+-------------------------------------------------+
SELECT json_get_bool(j, 'a.b.c') FROM jsons;
+--------------------------------------+
| json_get_bool(jsons.j,Utf8("a.b.c")) |
+--------------------------------------+
| |
| |
| |
| true |
+--------------------------------------+
SELECT json_get_int(j, 'a.b["c"]') FROM jsons;
+----------------------------------------+
| json_get_int(jsons.j,Utf8("a.b["c"]")) |
+----------------------------------------+
| 1 |
| |
| |
| 1 |
+----------------------------------------+
SELECT json_to_string(json_get_object(j, 'a.b')) FROM jsons;
+------------------------------------------------------+
| json_to_string(json_get_object(jsons.j,Utf8("a.b"))) |
+------------------------------------------------------+
| {"c":1} |
| {"c":1.234} |
| {"c":"foo"} |
| {"c":true} |
+------------------------------------------------------+
SELECT json_get_string(json_get_object(j, 'a.b'), 'c') FROM jsons;
+-----------------------------------------------------------------+
| json_get_string(json_get_object(jsons.j,Utf8("a.b")),Utf8("c")) |
+-----------------------------------------------------------------+
| 1 |
| 1.234 |
| foo |
| true |
+-----------------------------------------------------------------+
SELECT json_get_object(j, 'a.x') FROM jsons;
+--------------------------------------+
| json_get_object(jsons.j,Utf8("a.x")) |
+--------------------------------------+
| |
| |
| |
| |
+--------------------------------------+
DROP TABLE jsons;
Affected Rows: 0
-- test functions with arrays --
CREATE TABLE jsons(j JSON, ts timestamp time index);
Affected Rows: 0
INSERT INTO jsons VALUES(parse_json('["a", "bcde", "", "Long time ago, there is a little pig flying in the sky"]'), 1);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('[true, false, false, false]'), 2);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('[1, 0, -2147483649, 2147483648]'), 3);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('[1.2, 3.1415926535897932384626, -3e123, 1e100]'), 4);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('[{"a": {"i": 1}}, {"a": {"i": 2}}, {"a": {"i": 3}}]'), 5);
Affected Rows: 1
SELECT json_get_int(j, '[0]') FROM jsons;
+-----------------------------------+
| json_get_int(jsons.j,Utf8("[0]")) |
+-----------------------------------+
| |
| 1 |
| 1 |
| |
| |
+-----------------------------------+
SELECT json_get_float(j, '[1]') FROM jsons;
+-------------------------------------+
| json_get_float(jsons.j,Utf8("[1]")) |
+-------------------------------------+
| |
| 0.0 |
| 0.0 |
| 3.141592653589793 |
| |
+-------------------------------------+
SELECT json_get_bool(j, '[2]') FROM jsons;
+------------------------------------+
| json_get_bool(jsons.j,Utf8("[2]")) |
+------------------------------------+
| |
| false |
| |
| |
| |
+------------------------------------+
SELECT json_get_string(j, '[3]') FROM jsons;
+--------------------------------------------------------+
| json_get_string(jsons.j,Utf8("[3]")) |
+--------------------------------------------------------+
| Long time ago, there is a little pig flying in the sky |
| false |
| 2147483648 |
| 1e100 |
| |
+--------------------------------------------------------+
SELECT json_to_string(json_get_object(j, '[0]')) FROM jsons;
+------------------------------------------------------+
| json_to_string(json_get_object(jsons.j,Utf8("[0]"))) |
+------------------------------------------------------+
| |
| |
| |
| |
| {"a":{"i":1}} |
+------------------------------------------------------+
SELECT json_get_int(json_get_object(j, '[0]'), 'a.i') FROM jsons;
+----------------------------------------------------------------+
| json_get_int(json_get_object(jsons.j,Utf8("[0]")),Utf8("a.i")) |
+----------------------------------------------------------------+
| |
| |
| |
| |
| 1 |
+----------------------------------------------------------------+
SELECT json_get_int(json_get_object(j, '[9]'), 'a.i') FROM jsons;
+----------------------------------------------------------------+
| json_get_int(json_get_object(jsons.j,Utf8("[9]")),Utf8("a.i")) |
+----------------------------------------------------------------+
| |
| |
| |
| |
| |
+----------------------------------------------------------------+
SELECT json_get(j, '[0]')::int8 FROM jsons;
+---------------------------------------------------------+
| arrow_cast(json_get(jsons.j,Utf8("[0]")),Utf8("Int64")) |
+---------------------------------------------------------+
| |
| 1 |
| 1 |
| |
| |
+---------------------------------------------------------+
SELECT json_get(j, '[0]')::double FROM jsons;
+-------------------------------+
| json_get(jsons.j,Utf8("[0]")) |
+-------------------------------+
| |
| 1.0 |
| 1.0 |
| 1.2 |
| |
+-------------------------------+
SELECT json_get(j, '[1]')::int8 FROM jsons;
+---------------------------------------------------------+
| arrow_cast(json_get(jsons.j,Utf8("[1]")),Utf8("Int64")) |
+---------------------------------------------------------+
| |
| 0 |
| 0 |
| |
| |
+---------------------------------------------------------+
SELECT json_get(j, '[1]')::double FROM jsons;
+-------------------------------+
| json_get(jsons.j,Utf8("[1]")) |
+-------------------------------+
| |
| 0.0 |
| 0.0 |
| 3.141592653589793 |
| |
+-------------------------------+
SELECT json_get(j, '[2]')::bool FROM jsons;
+-----------------------------------------------------------+
| arrow_cast(json_get(jsons.j,Utf8("[2]")),Utf8("Boolean")) |
+-----------------------------------------------------------+
| |
| false |
| |
| |
| |
+-----------------------------------------------------------+
SELECT json_get(j, '[3]')::string FROM jsons;
+--------------------------------------------------------+
| json_get(jsons.j,Utf8("[3]")) |
+--------------------------------------------------------+
| Long time ago, there is a little pig flying in the sky |
| false |
| 2147483648 |
| 1e100 |
| |
+--------------------------------------------------------+
DROP TABLE jsons;
Affected Rows: 0
-- test functions in WHERE clause --
CREATE TABLE jsons(j JSON, ts timestamp time index);
Affected Rows: 0
INSERT INTO jsons VALUES(parse_json('{"a": {"b": {"c": 1}}}'), 1);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('{"a": {"b": {"c": 1.234}}}'), 2);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('{"a": {"b": {"c": "foo"}}}'), 3);
Affected Rows: 1
INSERT INTO jsons VALUES(parse_json('{"a": {"b": {"c": true}}}'), 4);
Affected Rows: 1
SELECT json_to_string(j) FROM jsons WHERE json_get_int(j, 'a.b.c') = 1;
+-------------------------+
| json_to_string(jsons.j) |
+-------------------------+
| {"a":{"b":{"c":1}}} |
| {"a":{"b":{"c":true}}} |
+-------------------------+
SELECT json_to_string(j) FROM jsons WHERE json_get_float(j, 'a.b.c') = 1.234;
+-------------------------+
| json_to_string(jsons.j) |
+-------------------------+
| {"a":{"b":{"c":1.234}}} |
+-------------------------+
SELECT json_to_string(j) FROM jsons WHERE json_get_string(j, 'a.b.c') = 'foo';
+-------------------------+
| json_to_string(jsons.j) |
+-------------------------+
| {"a":{"b":{"c":"foo"}}} |
+-------------------------+
SELECT json_to_string(j) FROM jsons WHERE json_get_bool(j, 'a.b.c') = true;
+-------------------------+
| json_to_string(jsons.j) |
+-------------------------+
| {"a":{"b":{"c":true}}} |
+-------------------------+
SELECT json_to_string(j) FROM jsons WHERE CAST(json_get_int(j, 'a.b.c') AS BOOLEAN);
+-------------------------+
| json_to_string(jsons.j) |
+-------------------------+
| {"a":{"b":{"c":1}}} |
| {"a":{"b":{"c":true}}} |
+-------------------------+
SELECT json_to_string(j) FROM jsons WHERE json_get_string(json_get_object(j, 'a.b'), 'c') == 'foo';
+-------------------------+
| json_to_string(jsons.j) |
+-------------------------+
| {"a":{"b":{"c":"foo"}}} |
+-------------------------+
SELECT json_to_string(j) FROM jsons WHERE json_to_string(json_get_object(j, 'a.b')) == '{"c":1}';
+-------------------------+
| json_to_string(jsons.j) |
+-------------------------+
| {"a":{"b":{"c":1}}} |
+-------------------------+
SELECT json_to_string(j) FROM jsons WHERE json_get_string(json_get_object(j, 'a.x'), 'c') == 'foo';
+-------------------------+
| json_to_string(jsons.j) |
+-------------------------+
+-------------------------+
DROP TABLE jsons;
Affected Rows: 0