-
Notifications
You must be signed in to change notification settings - Fork 145
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: Add json_object
command
#3242
base: main
Are you sure you want to change the base?
PPL: Add json_object
command
#3242
Conversation
core/src/main/java/org/opensearch/sql/expression/json/JsonFunctions.java
Outdated
Show resolved
Hide resolved
integ-test/src/test/java/org/opensearch/sql/ppl/JsonFunctionIT.java
Outdated
Show resolved
Hide resolved
27299f2
to
7eb5979
Compare
} | ||
|
||
@Override | ||
public Pair<FunctionSignature, FunctionBuilder> resolve( |
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.
@acarbonetto a naive question - do we have more use cases of kv pairs such as this one ?
if so would it make sense to move this code into a more generic place?
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.
Interesting question - no. json_object is very unique. Although we do have cases of path-value pairings, we're going to treat them differently.
core/src/main/java/org/opensearch/sql/expression/operator/convert/TypeCastOperators.java
Outdated
Show resolved
Hide resolved
|
||
List<String> validJsonStrings = | ||
List.of( | ||
// test json objects are valid |
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.
can you plz add more complex nested use cases here ?
for example inner obj with and array side by an 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.
We need the json_array
function to do that. I've added a TODO in the tests to add this test in the future.
core/src/test/java/org/opensearch/sql/expression/operator/convert/TypeCastOperatorTest.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/opensearch/sql/expression/operator/convert/TypeCastOperatorTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
….java Co-authored-by: Andrew Carbonetto <[email protected]> Signed-off-by: kenrickyap <[email protected]>
Signed-off-by: Kenrick Yap <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
50449b0
to
4759311
Compare
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
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.
What is the purpose of that API? It looks kinda useless.
Are there future plans for other features where it could be used?
As mentioned in the RFC, this API mirrors the Splunk SP2 api and would be helpful for migrating to sharing data between apis. |
This PR depends on the
json_valid
command: #3230Description
For OpenSearch-PPL, adds the json_object() functions that takes a even number of varargs (key/value pairs). Returns an expression type that is valid json object (STRUCT).
Related Issues
Resolves #3208
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.