Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add doc of json_extract_float64 and json_extract_string #1124

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

yangj1211
Copy link
Collaborator

@yangj1211 yangj1211 commented Sep 9, 2024

What type of PR is this?

  • Enhancement
  • Displaying
  • Typo
  • Doc Request

Which issue(s) this PR fixes:

issue #588,#1134

What this PR does / why we need it:

Copy link

@aronchanisme aronchanisme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有个地方需要注意一下:

mysql> create table test_123(c1 json);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into test_123 values ('{"a1":10, "a2":20}');
Query OK, 1 row affected (0.01 sec)

mysql> select * from test_123;
+----------------------+
| c1                   |
+----------------------+
| {"a1": 10, "a2": 20} |
+----------------------+
1 row in set (0.00 sec)

mysql> select json_extract_float64(c1, '$.a1, $.a2') from test_123;
ERROR 20301 (HY000): invalid input: invalid json path '$.a1, $.a2'
mysql> select json_extract_float64(c1, '$.a1', '$.a2') from test_123;
+--------------------------------------+
| json_extract_float64(c1, $.a1, $.a2) |
+--------------------------------------+
|                                 NULL |
+--------------------------------------+
1 row in set (0.00 sec)

mysql> select json_extract_float64(c1, '$.a1') from test_123;
+--------------------------------+
| json_extract_float64(c1, $.a1) |
+--------------------------------+
|                             10 |
+--------------------------------+
1 row in set (0.00 sec)

mysql> select json_extract(c1, '$.a1') from test_123;
+------------------------+
| json_extract(c1, $.a1) |
+------------------------+
| 10                     |
+------------------------+
1 row in set (0.00 sec)

mysql> select json_extract(c1, '$.a1', '$.a2') from test_123;
+------------------------------+
| json_extract(c1, $.a1, $.a2) |
+------------------------------+
| [10, 20]                     |
+------------------------------+
1 row in set (0.00 sec)

mysql> select json_extract_float64(c1, '$.a1', '$.a2') from test_123;
+--------------------------------------+
| json_extract_float64(c1, $.a1, $.a2) |
+--------------------------------------+
|                                 NULL |
+--------------------------------------+
1 row in set (0.00 sec)

mysql> select json_extract_string(c1, '$.a1', '$.a2') from test_123;
+-------------------------------------+
| json_extract_string(c1, $.a1, $.a2) |
+-------------------------------------+
| NULL                                |
+-------------------------------------+
1 row in set (0.00 sec)

mysql> insert into test_123 values ('{"a1":"test", "a2":"test2"}');
Query OK, 1 row affected (0.00 sec)

mysql> select * from test_123;
+-------------------------------+
| c1                            |
+-------------------------------+
| {"a1": 10, "a2": 20}          |
| {"a1": "test", "a2": "test2"} |
+-------------------------------+
2 rows in set (0.00 sec)

mysql> select json_extract_string(c1, '$.a1', '$.a2') from test_123;
+-------------------------------------+
| json_extract_string(c1, $.a1, $.a2) |
+-------------------------------------+
| NULL                                |
| NULL                                |
+-------------------------------------+
2 rows in set (0.00 sec)

mysql> select json_extract_string(c1, '$.a1') from test_123;
+-------------------------------+
| json_extract_string(c1, $.a1) |
+-------------------------------+
| NULL                          |
| test                          |
+-------------------------------+
2 rows in set (0.00 sec)

@yangj1211 yangj1211 requested a review from allengaoo October 25, 2024 07:21
@yangj1211 yangj1211 merged commit 250888e into matrixorigin:main Oct 28, 2024
1 check passed
@yangj1211 yangj1211 deleted the json_extract branch October 30, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants