-
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
DRAFT - Add support for highlight in PPL #107
Conversation
Codecov Report
@@ Coverage Diff @@
## draft-highlight-in-ppl #107 +/- ##
============================================================
+ Coverage 94.85% 94.88% +0.02%
- Complexity 2913 2926 +13
============================================================
Files 288 289 +1
Lines 7839 7879 +40
Branches 571 573 +2
============================================================
+ Hits 7436 7476 +40
Misses 349 349
Partials 54 54
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 |
* Bump checkstyle version and fix violations Signed-off-by: Chen Dai <daichen@amazon.com> * Fix checkstyle violations in test code Signed-off-by: Chen Dai <daichen@amazon.com> Signed-off-by: Chen Dai <daichen@amazon.com>
*/ | ||
@Override | ||
public LogicalPlan visitHighlight(Highlight node, AnalysisContext context) { | ||
LogicalPlan child = node.getChild().get(0).accept(this, 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.
Just to confirm that .get(0)
won't crash if there is no such element.
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 don't believe this case would be possible. As well the returning object at index 0
is standard for visit functions in the Analyzer
.
public T visitHighlightFunction(HighlightFunction node, C context) { | ||
return visitChildren(node, context); | ||
} | ||
|
||
public T visitHighlight(Highlight node, C context) { | ||
return visitChildren(node, 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.
What is the difference?
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.
visitHighlightFunction
takes a HighlightFunction
node and has an overriding function in ExpressionAnalyzer
, while visitHighlight
takes a highlight
node and has an overriding function in Analyzer
. This is because for PPL
I was unable to resolve a highlight field as an expression like I did in SQL
. Instead I use HighlightOperator
and use the Analyzer
to get around this issue. This issue arose because of the way the parser was implemented, the function highlight
syntax of not having highlight
in a fields
command, and the parser implementation of AllFields
without a fields command.
We may want to consider updating SQL to use the highlightOperator
rather than HighlightExpression
...
@forestmvey I didn't realize you recreated the PR. Please have a look at my comments to the previous PR here. |
@@ -79,4 +79,8 @@ public R visitMLCommons(PhysicalPlan node, C context) { | |||
public R visitAD(PhysicalPlan node, C context) { | |||
return visitNode(node, context); | |||
} | |||
|
|||
public R visitHighlight(PhysicalPlan node, C 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.
What's the difference between visitHighlight and visitAD?
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.
AD and highlight operators need their own visiting functions to be called from their derived classes. You can find the overriding functions in OpenSearchExecutionProtector
. The nodes passed into these functions will be for their respective HighlightOperator
and ADOperator
. This way the operator nodes are passed in, we can successfully visit the input for each node.
@@ -607,6 +609,26 @@ public void testParseCommand() { | |||
)); | |||
} | |||
|
|||
@Test | |||
public void testStringLiteralHighlightCommand() { | |||
assertEqual("source=t | highlight('FieldA')", |
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 double quotes be used in the highlight parameter? If so, should it be tested?
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.
Yes double quotes in highlight parameter are supported. Both single and double quoted parameters will be interpreted as string literals at this parsing level. I don't think it's overly necessary to add a test for it at this level.
@@ -25,7 +25,6 @@ | |||
import static org.opensearch.sql.ast.dsl.AstDSL.exprList; | |||
import static org.opensearch.sql.ast.dsl.AstDSL.field; | |||
import static org.opensearch.sql.ast.dsl.AstDSL.filter; | |||
import static org.opensearch.sql.ast.dsl.AstDSL.floatLiteral; |
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.
Was this just an unused import?
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.
Yes this was just an un-used import.
875bbb7
to
978eb62
Compare
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
HighlightFunction is converted to LogicalHighlight logical plan. Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
…Improved test coverage and fixing checkstyle errors. Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
…ing coverage for OpenSearchIndexScan Signed-off-by: forestmvey <forestv@bitquilltech.com>
…light acceptance as a string literal as well as qualified name. Signed-off-by: forestmvey <forestv@bitquilltech.com>
…ht call in PhysicalPlanNodeVisitor.. Signed-off-by: forestmvey <forestv@bitquilltech.com>
…roject. Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
…quotes. Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
…rchExecutionrotector. Refine HighlightOperator logic. Signed-off-by: forestmvey <forestv@bitquilltech.com>
…tFunction in Analyzer as this case should not be reachable. Signed-off-by: forestmvey <forestv@bitquilltech.com>
…ations from HighlightOperator. Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
e00dba1
to
c656026
Compare
Signed-off-by: forestmvey <forestv@bitquilltech.com>
Description
Add PPL support for highlight in SQL plugin.
Issues Resolved
Issue: github-636
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.