-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce JSON_EXTRACT function (#4743)
* Introduce JSON_EXTRACT function close: #3513 Note, we don't support the path argument in this phase * address jievince's review commit removed the unecessary interface of construct Map from Value * Type handling Only primitive types are supported * Support depth1 nested * lint: fmt * ut: ctest, fixed wrong expression of Map * fix ut errors * tck: case for json_extract added Co-authored-by: Sophie <[email protected]>
- Loading branch information
1 parent
3a454be
commit f1fb9e9
Showing
6 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Feature: Fetch Int Vid Edges | ||
Feature: Coalesce Function | ||
|
||
Background: | ||
Test coalesce function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Feature: json_extract Function | ||
|
||
Background: | ||
Test json_extract function | ||
|
||
Scenario: Test Positive Cases | ||
When executing query: | ||
""" | ||
YIELD JSON_EXTRACT('{"a": "foo", "b": 0.2, "c": true}') AS result; | ||
""" | ||
Then the result should be, in any order: | ||
| result | | ||
| {a: "foo", b: 0.2, c: true} | | ||
When executing query: | ||
""" | ||
YIELD JSON_EXTRACT('{"a": 1, "b": {}, "c": {"d": true}}') AS result; | ||
""" | ||
Then the result should be, in any order: | ||
| result | | ||
| {a: 1, b: {}, c: {d: true}} | | ||
When executing query: | ||
""" | ||
YIELD JSON_EXTRACT('{}') AS result; | ||
""" | ||
Then the result should be, in any order: | ||
| result | | ||
| {} | | ||
|
||
Scenario: Test Cases With Invalid JSON String | ||
When executing query: | ||
""" | ||
YIELD JSON_EXTRACT('fuzz') AS result; | ||
""" | ||
Then the result should be, in any order: | ||
| result | | ||
| BAD_DATA | | ||
When executing query: | ||
""" | ||
YIELD JSON_EXTRACT(3.1415926) AS result; | ||
""" | ||
Then a SemanticError should be raised at runtime: `JSON_EXTRACT(3.1415926)' is not a valid expression : Parameter's type error | ||
Scenario: Test Cases Hitting Limitations | ||
# Here nested Map depth is 2, the nested item is omitted: | ||
When executing query: | ||
""" | ||
YIELD JSON_EXTRACT('{"a": "foo", "b": false, "c": {"d": {"e": 0.1}}}') AS result; | ||
""" | ||
Then the result should be, in any order: | ||
| result | | ||
| {a: "foo", b: false, c: {}} | | ||
# Here List is not yet supported, the encounted value is omitted: | ||
When executing query: | ||
""" | ||
YIELD JSON_EXTRACT('{"a": "foo", "b": false, "c": [1, 2, 3]}') AS result; | ||
""" | ||
Then the result should be, in any order: | ||
| result | | ||
| {a: "foo", b: false} | |