-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve Array and ExprValue Parsing With Inner Hits #274
Improve Array and ExprValue Parsing With Inner Hits #274
Conversation
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Codecov Report
@@ Coverage Diff @@
## integ-support-inner-hits-exprvalue #274 +/- ##
=====================================================================
Coverage 97.27% 97.28%
- Complexity 4330 4354 +24
=====================================================================
Files 388 388
Lines 10807 10845 +38
Branches 761 769 +8
=====================================================================
+ Hits 10513 10551 +38
Misses 287 287
Partials 7 7
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Nice!
Can you add more integration tests? Array inside array? (is it possible in OpenSearch though?)
How it works with nested
function? For example nested(a.b)
where a
and/or b
is array of multiple objects.
Does it change behavior shown in opensearch-project#1300?
opensearch/src/main/java/org/opensearch/sql/opensearch/data/utils/OpenSearchJsonContent.java
Show resolved
Hide resolved
...earch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Outdated
Show resolved
Hide resolved
...earch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Outdated
Show resolved
Hide resolved
I can probably add some logic to maintain the old functionality for non inner hits parsing, I am adding logic to maintain the previous V2 array support! |
Would this be a breaking change for arrays support? Right now, we have the following behaviours:
My preference is to reserve 4. logic to partiQL syntax. Here's my thoughts: Using PartiQL search would be the 'common way' to flatten (using cartesian product) as the syntax and logic is the most relational. PartiQL syntax would define a join between multiple 'tables' (ie, join between the main index and any inner hits of a nested, join, or any array's object). The We don't have a way for V2 engine to behave like PPL and return the json array object - and maybe that's fine for now. If there is interest, we could investigate ways to use flat-type to support this functionality. |
Probably, you had a typo. Can you test your code with this sample?
search result: {
"took" : 361,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "dbg",
"_id" : "uDBnoYgB5NyEnr3HyanK",
"_score" : 1.0,
"_source" : {
"obj" : [
[
1,
2
],
[
3,
4
],
5
]
}
}
]
}
} mapping: {
"dbg" : {
"aliases" : { },
"mappings" : {
"properties" : {
"obj" : {
"type" : "long"
}
}
},
"settings" : {
"index" : {
"creation_date" : "1686168574104",
"number_of_shards" : "1",
"number_of_replicas" : "1",
"uuid" : "LN-lYUQFSsi9MVpa5VT-Zg",
"version" : {
"created" : "136297827"
},
"provided_name" : "dbg"
}
}
}
} |
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
…arrays of non-object type with inner_hits. Signed-off-by: forestmvey <forestv@bitquilltech.com>
opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java
Outdated
Show resolved
Hide resolved
…them. Signed-off-by: forestmvey <forestv@bitquilltech.com>
…ponse. Signed-off-by: forestmvey <forestv@bitquilltech.com>
...earch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Show resolved
Hide resolved
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.
Looks good.
I noted a couple small improvements.
opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java
Outdated
Show resolved
Hide resolved
opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java
Outdated
Show resolved
Hide resolved
...earch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Show resolved
Hide resolved
...earch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Show resolved
Hide resolved
...earch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Outdated
Show resolved
Hide resolved
...earch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Show resolved
Hide resolved
...earch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java
Show resolved
Hide resolved
opensearch/src/main/java/org/opensearch/sql/opensearch/response/OpenSearchResponse.java
Outdated
Show resolved
Hide resolved
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Description
With the addition of the nested function support in the V2 engine the
inner_hits
portion of the OS response needs to be parsed for OS types. Previously arrays were not entirely parsed due to lack of support.Functionality Changes
Parsing of each value in arrays needs to be supported for proper
nested
functionality. The following gives examples of the response formats when parsing arrays.Object Type - Array Of Objects
Dataset:
"obj": [{"key": "val1"}, {"key": "val2"}]
SQL Query:
V1 Engine Response:
[{'key': 'val1'},{'key': 'val2'}]
V2 Engine Response:
{'key': 'val1'}
Nested Type - Array Of Objects
Dataset:
"obj": [{"key": "val1"}, {"key": "val2"}]
SQL Query:
V1 and V2 Engine Response:
[{'key': 'val1'},{'key': 'val2'}]
Array Of Values (Nested only supports objects and not arrays of values):
Dataset:
"obj": ["val1", "val2"]
SQL Query:
V1 Engine Response:
['val1','val2']
V2 Engine Response:
{'val1'}
Issues Resolved
Issue: 1686
Check List
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.