-
Notifications
You must be signed in to change notification settings - Fork 34
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
PPL support json_delete, append functions #971
Changes from 14 commits
9de4fa5
2bde70b
b7b0713
af8144a
bf6e607
bb8bd30
9dbc89e
a46494c
3fe3adb
88bcaea
09b7b5c
f76ee37
fe8d600
45fc073
2124fad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,89 @@ Example: | |
+----------------+ | ||
|
||
|
||
### `JSON_DELETE` | ||
|
||
**Description** | ||
|
||
`json_delete(json, [keys list])` Deletes json elements from a json object based on json specific keys. Return the updated object after keys deletion . | ||
|
||
**Argument type:** JSON, List<STRING> | ||
|
||
**Return type:** JSON | ||
|
||
A JSON object format. | ||
|
||
Example: | ||
|
||
os> source=people | eval deleted = json_delete({"a":"valueA", "b":"valueB"}, array("a")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this query work? Is it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the documentation with the examples to match the actual test |
||
fetched rows / total rows = 1/1 | ||
+----------------------------------+ | ||
| deleted | | ||
+----------------------------------+ | ||
| {"a": "valueA" } | | ||
+----------------------------------+ | ||
|
||
os> source=people | eval deleted = json_delete({"a":[{"b":1},{"b":2},{"c":3}]}, array("a.b")) | ||
fetched rows / total rows = 1/1 | ||
+-----------------------------------------------------------+ | ||
| deleted | | ||
+-----------------------------------------------------------+ | ||
| {"a":[{"c":3}] } | | ||
+-----------------------------------------------------------+ | ||
|
||
os> source=people | eval `no_action` = json_delete({"a":[{"b":1},{"b":2},{"c":3}]}, array("b.b")) | ||
fetched rows / total rows = 1/1 | ||
+-----------------------------------+ | ||
| no_action | | ||
+-----------------------------------+ | ||
| {"a":[{"b":1},{"b":2},{"c":3}]} | | ||
+-----------------------------------+ | ||
|
||
### `JSON_APPEND` | ||
|
||
**Description** | ||
|
||
`json_append(json, [path_key, list of values to add ])` appends values to end of an array within the json elements. Return the updated json object after appending . | ||
|
||
**Argument type:** JSON, List<STRING> | ||
|
||
**Return type:** JSON | ||
|
||
A JSON object format. | ||
|
||
**Note** | ||
Append adds the value to the end of the existing array with the following cases: | ||
- path is an object value - append is ignored and the value is returned | ||
- path is an existing array not empty - the value are added to the array's tail | ||
- path not found - the value are added to the root of the json tree | ||
- path is an existing array is empty - create a new array with the given value | ||
|
||
Example: | ||
|
||
os> source=people | eval append = json_append(`{"a":["valueA", "valueB"]}`, array('a', 'valueC', 'valueD')) | ||
fetched rows / total rows = 1/1 | ||
+-------------------------------------------------+ | ||
| append | | ||
+-------------------------------------------------+ | ||
| {"a":["valueA", "valueB", "valueC", "valueD"]} | | ||
+-------------------------------------------------+ | ||
|
||
os> source=people | eval append = json_append(`{"a":[]}`, array('a', 'valueC')) | ||
fetched rows / total rows = 1/1 | ||
+-----------------------------------------------+ | ||
| append | | ||
+-----------------------------------------------+ | ||
| {"a":["valueC"]} | | ||
+-----------------------------------------------+ | ||
|
||
os> source=people | eval append = json_append(`{"root":{ "a":["valueA", "valueB"]}}`, array('root', 'valueC') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a |
||
fetched rows / total rows = 1/1 | ||
+-----------------------------------------------+ | ||
| append | | ||
+-----------------------------------------------+ | ||
|{"root": {"a":["valueA", "valueB"]}} | | ||
LantaoJin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+-----------------------------------------------+ | ||
|
||
### `JSON_KEYS` | ||
|
||
**Description** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the input
json
should bejsonString
and type here isSTRING, List<STRING>
?