-
Notifications
You must be signed in to change notification settings - Fork 33
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
PPL support json_delete, append functions #971
Conversation
- json_delete - json_append - json_extend Signed-off-by: YANGDB <[email protected]>
- json_delete - json_append - json_extend Signed-off-by: YANGDB <[email protected]>
Signed-off-by: YANGDB <[email protected]>
Signed-off-by: YANGDB <[email protected]>
Signed-off-by: YANGDB <[email protected]>
Signed-off-by: YANGDB <[email protected]>
docs/ppl-lang/functions/ppl-json.md
Outdated
| {"a": "valueA" } | | ||
+----------------------------------+ | ||
|
||
os> source=people | eval eval deleted = json_delete({"a":[{"b":1},{"b":2},{"c":3}]}, json_array("a.b")) |
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.
duplicated eval
docs/ppl-lang/functions/ppl-json.md
Outdated
|
||
Example: | ||
|
||
os> source=people | eval deleted = json_delete({"a":"valueA", "b":"valueB"}, json_array("a")) |
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.
Since the second parameter is a json_array, can we add an example to drop two elements?json_delete({"a":"valueA", "b":"valueB", "c": "valueC"}, json_array("a", "b"))
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.
Actually, I think here we should directly use array("a")
instead of json_array("a")
. We have supported array
function. json_array("a")
is to build a json_array type with item value "a".
docs/ppl-lang/functions/ppl-json.md
Outdated
+-------------------------------------------------------------+ | ||
| extend | | ||
+-------------------------------------------------------------+ | ||
| {"a":["valueA", "valueB", {"b":"valueC"}, {"b":"valueD"}]} | |
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.
How did you achieve this? Only the same data type could be added in a Spark Array.
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.
Ok, I see, you are handling json string instead of Spark named_struct
and array
Signed-off-by: YANGDB <[email protected]>
json_delete json_append Signed-off-by: YANGDB <[email protected]>
json_delete json_append Signed-off-by: YANGDB <[email protected]>
Signed-off-by: YANGDB <[email protected]>
@LantaoJin can u plz review again ?
|
Signed-off-by: YANGDB <[email protected]>
docs/ppl-lang/functions/ppl-json.md
Outdated
| {"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 comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a )
in the end.
docs/ppl-lang/functions/ppl-json.md
Outdated
|
||
`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> |
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 be jsonString
and type here is STRING, List<STRING>
?
docs/ppl-lang/functions/ppl-json.md
Outdated
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Does this query work? Is it json_delete('{"a":"valueA", "b":"valueB"}', array("a"))
?
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.
I've updated the documentation with the examples to match the actual test
Signed-off-by: YANGDB <[email protected]>
Description
Add PPL support for the following json functions
json_delete
json_append
Related Issues
#970
Check List
--signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.