Add Support for Nested Function Use In WHERE Clause Predicate Expresion by forestmvey · Pull Request #1657 · opensearch-project/sql · GitHub
Skip to content

Add Support for Nested Function Use In WHERE Clause Predicate Expresion#1657

Merged
acarbonetto merged 2 commits into
opensearch-project:mainfrom
Bit-Quill:integ-nested-where-clause-predicate-expression
May 30, 2023
Merged

Add Support for Nested Function Use In WHERE Clause Predicate Expresion#1657
acarbonetto merged 2 commits into
opensearch-project:mainfrom
Bit-Quill:integ-nested-where-clause-predicate-expression

Conversation

@forestmvey

Copy link
Copy Markdown
Collaborator

Description

Syntax: nested( [field] | [field,path] )

Add support for use of the nested function in the WHERE clause as a predicate expression. Supports nested function on left of operator, and literal on right. When using nested function in WHERE clause, the inner hits of the query are not added to the nested query DSL. To do this you must use the nested function in conjunction with a SELECT clause nested function call. See documentation for this nested implementation HERE (WIP).

Example Queries

SELECT message.info FROM nested_objects WHERE nested(message.info, message) = 'a';
SELECT nested(message.info) FROM nested_objects WHERE nested(message.info, message) = 'a';
SELECT message.info FROM nested_objects WHERE nested(message.info) = 'a' OR nested(comment.data) = 'b' AND nested(message.dayOfWeek) = 4;

Issues Resolved

Issue: 1111

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --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.

@codecov

codecov Bot commented May 25, 2023

Copy link
Copy Markdown

Comment thread core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? HAVING implemented the same way as WHERE

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand your question, but I implemented the fallback mechanism in AstBuilder to allow for a fallback specific to the nested function used in the HAVING clause. The old fallback mechanism could not determine between clauses for the filter, and we now support nested in the WHERE clause and not the HAVING so we need to differentiate between nested used in each.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you remove this check, nested would be automatically supported in HAVING, so why not? Less complexity, more functionality.

@forestmvey forestmvey May 30, 2023

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, may just work as is, though group by is not supported for nested yet. Will need to verify and add tests though, if it fits in the timeline maybe we can support in this release.

Comment thread sql/src/main/java/org/opensearch/sql/sql/parser/AstBuilder.java
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
@forestmvey forestmvey force-pushed the integ-nested-where-clause-predicate-expression branch from 5dc02e0 to eb48a0a Compare May 30, 2023 16:50
@acarbonetto acarbonetto merged commit 6d796ee into opensearch-project:main May 30, 2023
@acarbonetto acarbonetto deleted the integ-nested-where-clause-predicate-expression branch May 30, 2023 17:59
opensearch-trigger-bot Bot pushed a commit that referenced this pull request May 30, 2023
…on (#1657)

* Adding support for nested function used in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

* Add support for LIKE with nested query in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

---------

Signed-off-by: forestmvey <forestv@bitquilltech.com>
(cherry picked from commit 6d796ee)
opensearch-trigger-bot Bot pushed a commit that referenced this pull request May 30, 2023
…on (#1657)

* Adding support for nested function used in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

* Add support for LIKE with nested query in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

---------

Signed-off-by: forestmvey <forestv@bitquilltech.com>
(cherry picked from commit 6d796ee)
forestmvey added a commit that referenced this pull request May 30, 2023
…on (#1657)

Signed-off-by: forestmvey <forestv@bitquilltech.com>
forestmvey added a commit that referenced this pull request May 30, 2023
…on (#1657)

Signed-off-by: forestmvey <forestv@bitquilltech.com>
acarbonetto pushed a commit that referenced this pull request May 30, 2023
…on (#1657) (#1672)

Signed-off-by: forestmvey <forestv@bitquilltech.com>
Co-authored-by: forestmvey <forestv@bitquilltech.com>
acarbonetto pushed a commit that referenced this pull request May 30, 2023
…on (#1657) (#1673)

Signed-off-by: forestmvey <forestv@bitquilltech.com>
Co-authored-by: forestmvey <forestv@bitquilltech.com>
@Yury-Fridlyand Yury-Fridlyand mentioned this pull request May 30, 2023
6 tasks
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jun 12, 2023
…on (opensearch-project#1657)

* Adding support for nested function used in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

* Add support for LIKE with nested query in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

---------

Signed-off-by: forestmvey <forestv@bitquilltech.com>
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jun 12, 2023
…on (opensearch-project#1657)

* Adding support for nested function used in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

* Add support for LIKE with nested query in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

---------

Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jun 12, 2023
…on (opensearch-project#1657)

* Adding support for nested function used in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

* Add support for LIKE with nested query in predicate expression.

Signed-off-by: forestmvey <forestv@bitquilltech.com>

---------

Signed-off-by: forestmvey <forestv@bitquilltech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants