Skip to content

Commit

Permalink
Revert "[feature](function) add json->operator convert to json_extract (
Browse files Browse the repository at this point in the history
#19899)" (#24679)

Revert "[feature](function) add json->operator convert to json_extract (#19899)"
because it conflict with lambda syntax
This reverts commit f54a068.
  • Loading branch information
LiBinfeng-01 authored Sep 20, 2023
1 parent 677b342 commit 2e85e01
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ BIGINT json_extract_bigint(JSON j, VARCHAR json_path)
LARGEINT json_extract_largeint(JSON j, VARCHAR json_path)
DOUBLE json_extract_double(JSON j, VARCHAR json_path)
STRING json_extract_string(JSON j, VARCHAR json_path)
VARCHAR json_str->json_path
```

json_extract functions extract field specified by json_path from JSON. A series of functions are provided for different datatype.
Expand Down Expand Up @@ -128,22 +127,6 @@ mysql> SELECT json_extract('{"id": 123, "name": "doris"}', '$.aaa', '$.name');
| [null,"doris"] |
+-----------------------------------------------------------------+
1 row in set (0.01 sec)
mysql> SELECT '{"id": 123, "name": "doris"}'->'$.name';
+--------------------------------------------------------+
| json_extract('{"id": 123, "name": "doris"}', '$.name') |
+--------------------------------------------------------+
| "doris" |
+--------------------------------------------------------+
1 row in set (0.01 sec)
mysql> SELECT '{"k1": "v1", "k2": { "k21": 6.6, "k22": [1, 2, 3] } }'->'$.k2.k22[2]';
+--------------------------------------------------------------------------------------+
| json_extract('{"k1": "v1", "k2": { "k21": 6.6, "k22": [1, 2, 3] } }', '$.k2.k22[2]') |
+--------------------------------------------------------------------------------------+
| 3 |
+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ BIGINT json_extract_bigint(JSON j, VARCHAR json_path)
LARGEINT json_extract_largeint(JSON j, VARCHAR json_path)
DOUBLE json_extract_double(JSON j, VARCHAR json_path)
STRING json_extract_string(JSON j, VARCHAR json_path)
VARCHAR json_str->json_path
```


Expand Down Expand Up @@ -104,22 +103,6 @@ mysql> SELECT json_extract('{"id": 123, "name": "doris"}', '$.aaa', '$.name');
| [null,"doris"] |
+-----------------------------------------------------------------+
1 row in set (0.01 sec)
mysql> SELECT '{"id": 123, "name": "doris"}'->'$.name';
+--------------------------------------------------------+
| json_extract('{"id": 123, "name": "doris"}', '$.name') |
+--------------------------------------------------------+
| "doris" |
+--------------------------------------------------------+
1 row in set (0.01 sec)
mysql> SELECT '{"k1": "v1", "k2": { "k21": 6.6, "k22": [1, 2, 3] } }'->'$.k2.k22[2]';
+--------------------------------------------------------------------------------------+
| json_extract('{"k1": "v1", "k2": { "k21": 6.6, "k22": [1, 2, 3] } }', '$.k2.k22[2]') |
+--------------------------------------------------------------------------------------+
| 3 |
+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

### keywords
Expand Down
8 changes: 0 additions & 8 deletions fe/fe-core/src/main/cup/sql_parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,6 @@ precedence left KW_OVER;
precedence left KW_COLLATE;
precedence left KW_PARTITION;
precedence left KW_PARTITIONS;
precedence left ARROW;
precedence right KW_TEMPORARY;
precedence right LBRACKET;
precedence right LBRACE;
Expand Down Expand Up @@ -6723,13 +6722,6 @@ non_pred_expr ::=
{:
RESULT = new FunctionCallExpr("concat", exprs);
:}
| expr:e ARROW expr:index
{:
ArrayList<Expr> exprs = new ArrayList<>();
exprs.add(e);
exprs.add(index);
RESULT = new FunctionCallExpr("json_extract", new FunctionParams(exprs));
:}
| cast_expr:c
{: RESULT = c; :}
| case_expr:c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,6 @@ DORIS
-- !sql --
[6.6,[1,2,3],2]

-- !sql --
"doris"

-- !sql --
\N

-- !sql --
{"k21":6.6,"k22":[1,2,3]}

-- !sql --
3

-- !sql --
[1,2,3]

-- !sql --
doris

-- !sql --
123

-- !sql --
true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ suite("test_json_function") {
qt_sql "SELECT json_extract('{\"k1\": \"v1\", \"k2\": { \"k21\": 6.6, \"k22\": [1, 2, 3] } }', '\$.k1', '\$.k2');"
qt_sql "SELECT json_extract('{\"k1\": \"v1\", \"k2\": { \"k21\": 6.6, \"k22\": [1, 2, 3] } }', '\$.k2.k21', '\$.k2.k22', '\$.k2.k22[1]');"

qt_sql "SELECT '{\"id\": 123, \"name\": \"doris\"}'->'\$.name';"
qt_sql "SELECT null->'\$.id';"
qt_sql "SELECT '{\"k1\": \"v1\", \"k2\": { \"k21\": 6.6, \"k22\": [1, 2, 3] } }'->'\$.k2';"
qt_sql "SELECT '{\"k1\": \"v1\", \"k2\": { \"k21\": 6.6, \"k22\": [1, 2, 3] } }'->'\$.k2.k22[2]';"
qt_sql "SELECT '{\"k1\": \"v1\", \"k2\": { \"k21\": 6.6, \"k22\": [1, 2, 3] } }'->'\$.k2'->'\$.k22'"
qt_sql "SELECT json_unquote('{\"id\": 123, \"name\": \"doris\"}'->'\$.name');"
qt_sql "SELECT json_extract('{\"id\": 123, \"name\": \"doris\"}', '\$.id', '\$.name')->'\$.[0]';"

qt_sql "SELECT JSON_CONTAINS('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}','1','\$.a');"
qt_sql "SELECT JSON_CONTAINS('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}','1','\$.b');"
qt_sql "SELECT JSON_CONTAINS('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}','{\"d\": 4}','\$.a');"
Expand Down

0 comments on commit 2e85e01

Please sign in to comment.