mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-16 00:42:29 +00:00
* fix(json): upgrade jsonb to fix unterminated JSONPath panic Signed-off-by: luofucong <luofc@foxmail.com> * fix(json): align integer extraction with JSON2 conversions Signed-off-by: luofucong <luofc@foxmail.com> * style: format jsonb dependency declaration Signed-off-by: luofucong <luofc@foxmail.com> * fix(otlp): report concrete unsupported JSONB type names Signed-off-by: luofucong <luofc@foxmail.com> --------- Signed-off-by: luofucong <luofc@foxmail.com>
50 lines
2.5 KiB
Plaintext
50 lines
2.5 KiB
Plaintext
SELECT ts, json_get_int(j, 'n') AS n,
|
|
json_get_float(j, 'f') AS f,
|
|
json_get_string(j, 'big') AS big,
|
|
json_get_bool(j, 'flag') AS flag,
|
|
json_to_string(json_get_object(j, '$."a.b"')) AS nested
|
|
FROM jsonb_upgrade ORDER BY ts;
|
|
|
|
+-------------------------+-----+-------+----------------------+-------+-----------------------------------------+
|
|
| ts | n | f | big | flag | nested |
|
|
+-------------------------+-----+-------+----------------------+-------+-----------------------------------------+
|
|
| 1970-01-01T00:00:00.001 | -42 | 1.5 | 18446744073709551615 | true | {"items":[1,2,3],"name":"旧数据"} |
|
|
| 1970-01-01T00:00:00.002 | 0 | 0.125 | 0 | false | {"items":[],"name":"escaped \"quote\""} |
|
|
+-------------------------+-----+-------+----------------------+-------+-----------------------------------------+
|
|
|
|
INSERT INTO jsonb_upgrade VALUES
|
|
(3, parse_json('{"a.b":{"name":"new","items":[4,5]},"n":42,"f":2.5,"big":18446744073709551615,"flag":true,"nil":null}'));
|
|
|
|
Affected Rows: 1
|
|
|
|
ADMIN FLUSH_TABLE('jsonb_upgrade');
|
|
|
|
+------------------------------------+
|
|
| ADMIN FLUSH_TABLE('jsonb_upgrade') |
|
|
+------------------------------------+
|
|
| 0 |
|
|
+------------------------------------+
|
|
|
|
SELECT ts, json_get_int(j, 'n') AS n,
|
|
json_get_float(j, 'f') AS f,
|
|
json_get_string(j, 'big') AS big,
|
|
json_get_bool(j, 'flag') AS flag,
|
|
json_to_string(json_get_object(j, '$."a.b"')) AS nested
|
|
FROM jsonb_upgrade ORDER BY ts;
|
|
|
|
+-------------------------+-----+-------+----------------------+-------+-----------------------------------------+
|
|
| ts | n | f | big | flag | nested |
|
|
+-------------------------+-----+-------+----------------------+-------+-----------------------------------------+
|
|
| 1970-01-01T00:00:00.001 | -42 | 1.5 | 18446744073709551615 | true | {"items":[1,2,3],"name":"旧数据"} |
|
|
| 1970-01-01T00:00:00.002 | 0 | 0.125 | 0 | false | {"items":[],"name":"escaped \"quote\""} |
|
|
| 1970-01-01T00:00:00.003 | 42 | 2.5 | 18446744073709551615 | true | {"items":[4,5],"name":"new"} |
|
|
+-------------------------+-----+-------+----------------------+-------+-----------------------------------------+
|
|
|
|
SELECT SUM(json_get_int(j, 'n')) AS total FROM jsonb_upgrade;
|
|
|
|
+-------+
|
|
| total |
|
|
+-------+
|
|
| 0 |
|
|
+-------+
|