-
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
Add Nested Function Support in SELECT Clause #243
Conversation
Codecov Report
@@ Coverage Diff @@
## integ-nested-select-clause #243 +/- ##
================================================================
+ Coverage 98.46% 98.50% +0.03%
- Complexity 3869 3964 +95
================================================================
Files 345 351 +6
Lines 9603 9845 +242
Branches 616 653 +37
================================================================
+ Hits 9456 9698 +242
Misses 142 142
Partials 5 5
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.
Cool!
Doctests? Demo? Nested party?
core/src/main/java/org/opensearch/sql/expression/nested/NestedFunctions.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/nested/NestedFunctions.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/nested/NestedFunctions.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/nested/NestedFunctions.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanQueryBuilder.java
Show resolved
Hide resolved
sql/src/main/java/org/opensearch/sql/sql/parser/AstBuilder.java
Outdated
Show resolved
Hide resolved
sql/src/main/java/org/opensearch/sql/sql/parser/AstExpressionBuilder.java
Outdated
Show resolved
Hide resolved
sql/src/main/java/org/opensearch/sql/sql/parser/AstUnnestBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/analysis/NestedAnalyzer.java
Outdated
Show resolved
Hide resolved
e5221ba
to
03cd356
Compare
Does documentation/doctests need to be added? |
result = flatten(field, inputValue, result, true); | ||
} | ||
|
||
if (result.isEmpty()) { |
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.
when does this happen?
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.
Kept in place in-case of null values in data.
core/src/main/java/org/opensearch/sql/planner/physical/UnnestOperator.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/planner/physical/UnnestOperator.java
Outdated
Show resolved
Hide resolved
ExprValue row, | ||
List<Map<String, | ||
ExprValue>> prevList, | ||
boolean supportArrays |
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 we make supportArrays == false a separate function? Feels like these have different behaviours anyways
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 can but we will need another function that is almost the same as getNested
.
Added doctest in 10ee84d14f28b1c7e5bfa92a76e92cf9c2d74579 |
c7229e9
to
26aa7c6
Compare
NestedAnalyzer nestedAnalyzer = new NestedAnalyzer( | ||
namedExpressions, expressionAnalyzer, child | ||
); | ||
child = nestedAnalyzer.analyze(expr, context); |
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.
You overwrite child
set by highlightAnalyzer
, which overwrites child
set by windowAnalyzer
, which .... Is it safe? Is nested
compatible with highlight
?
Do you have [IT] tests for that?
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.
Don't believe we have any requirement for nested
to work with added V2 functionality like highlight
. Goal is legacy deprecation and we want to abandon the NLPChina implementation for a better standard like PartiQL. I can pushDown highlight
and nested
, I'm not sure what a valid query would be though?
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.
select nested(...), highlight(...) from ... where match(...)
Can you try this?
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.
Not working with Relevance Queries. Issue here for tracking.
1488
core/src/main/java/org/opensearch/sql/analysis/NestedAnalyzer.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/nested/NestedFunction.java
Outdated
Show resolved
Hide resolved
19f5c95
to
dc718e2
Compare
core/src/test/java/org/opensearch/sql/planner/physical/UnnestOperatorTest.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/OpenSearchFunctions.java
Outdated
Show resolved
Hide resolved
9b803d4
to
c02fa2a
Compare
Signed-off-by: forestmvey <forestv@bitquilltech.com>
c02fa2a
to
48553f3
Compare
Description
Syntax:
nested( [field} | [field,path] )
Nested function allows the query of nested types of an index. The
path
parameter is determined dynamically if not provided by the user, and the output query should be identical assuming the user input the correct parameter values. Thecondition
parameter is not supported when the nested function is used in theSELECT
clause. Nested types structure is flattened making the full path of an object the key, and the object it refers to the value.Example Queries
Simple nested query, array of
message.info
is flattened into two rows.SELECT nested(message.info) FROM nested_objects;
After flattening notice
comment.data
has repeatingab
SELECT nested(message.info), nested(comment.data) FROM nested_objects;
someField is of type object
SELECT nested(message.info), someField FROM nested_objects;
To Do
Not Supported
condition
parameter in theSELECT
clause.Changes from Legacy Functionality
condition
parameter in SELECT clause.partiql.rst
to handle object arrays same as V2 engine.Issues Resolved
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.