-
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
Update for SQL and PPL parser to accept simple_query_string
#53
Update for SQL and PPL parser to accept simple_query_string
#53
Conversation
… field list as the first argument. Signed-off-by: Yury Fridlyand <[email protected]>
Signed-off-by: Yury Fridlyand <[email protected]>
field=relevanceArgValue COMMA query=relevanceArgValue | ||
field=relevanceField COMMA query=relevanceQuery | ||
(COMMA relevanceArg)* RT_PRTHS | ||
| relevanceFunctionNameEx LT_PRTHS |
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.
Should we rename it? Like relevanceFunctionType1Name
and relevanceFunctionType2Name
.
Or maybe to make relevanceExpressionType1
and relevanceExpressionType2
.
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.
Please be explicit with your naming as possible. Type1 and Type2 don't mean anything. If there's an order associated with the types in the list (and no other way to differentiate the types) we can call them first and second or something similar.
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.
Let's change it to have separate rule for single-field relevance functions and a separate rule for multi-field relevance functions.
This way we can avoid the cumbersome ?:
in AstExpressionBuilder
. Instead there will be one method to visit single field relevance functions and another to visit multi-field relevance functions.
// all the arguments are defaulted to string values | ||
// to skip environment resolving and function signature resolving | ||
ImmutableList.Builder<UnresolvedExpression> builder = ImmutableList.builder(); | ||
ParserRuleContext field = ctx.field; | ||
if (field == null) | ||
field = ctx.fields; | ||
builder.add(new UnresolvedArgument("field", | ||
new Literal(StringUtils.unquoteText(ctx.field.getText()), DataType.STRING))); | ||
new Literal(StringUtils.unquoteText(field.getText()), DataType.STRING))); | ||
builder.add(new UnresolvedArgument("query", | ||
new Literal(StringUtils.unquoteText(ctx.query.getText()), DataType.STRING))); | ||
ctx.relevanceArg().forEach(v -> builder.add(new UnresolvedArgument( |
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.
- Should we create 2 different functions as
relevanceArguments
? - Should we skip
StringUtils.unquoteText
forfields
?
Could you please make the SQL Java CI actions pass? |
Signed-off-by: Yury Fridlyand <[email protected]>
dc75ce8 fixes code style, rest failures require tests. |
@@ -332,8 +336,12 @@ private List<UnresolvedExpression> relevanceArguments(RelevanceExpressionContext | |||
// all the arguments are defaulted to string values | |||
// to skip environment resolving and function signature resolving | |||
ImmutableList.Builder<UnresolvedExpression> builder = ImmutableList.builder(); | |||
ParserRuleContext field = ctx.field; | |||
if (field == null) { |
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.
use conditions to define the ParseRuleContext, for example:
ParserRuleContext field = ctx.field != null ? ctx.field : ctx.fields;
@@ -357,6 +358,8 @@ BIT_XOR_OP: '^'; | |||
DOT: '.'; | |||
LR_BRACKET: '('; | |||
RR_BRACKET: ')'; | |||
LT_SQR_PRTHS: '['; |
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.
where's this name coming from?
Just wondering why not something like: LR_SQUARE_BRACKET
and RR_SQUARE_BRACKET
@@ -362,8 +364,12 @@ public UnresolvedExpression visitConvertedDataType( | |||
|
|||
@Override | |||
public UnresolvedExpression visitRelevanceFunction(RelevanceFunctionContext ctx) { | |||
ParserRuleContext func = ctx.relevanceFunctionNameEx(); |
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.
ParserRuleContext func = ctx.relevanceFunctionNameEx() != null ctx.relevanceFunctionNameEx() : ctx.relevanceFunctionName();
@@ -393,8 +399,12 @@ private List<UnresolvedExpression> relevanceArguments(RelevanceFunctionContext c | |||
// all the arguments are defaulted to string values | |||
// to skip environment resolving and function signature resolving | |||
ImmutableList.Builder<UnresolvedExpression> builder = ImmutableList.builder(); | |||
ParserRuleContext field = ctx.field; |
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.
ParserRuleContext field = ctx.field != null ctx.field : ctx.field2;
field=relevanceArgValue COMMA query=relevanceArgValue | ||
field=relevanceField COMMA query=relevanceQuery | ||
(COMMA relevanceArg)* RT_PRTHS | ||
| relevanceFunctionNameEx LT_PRTHS |
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.
Let's change it to have separate rule for single-field relevance functions and a separate rule for multi-field relevance functions.
This way we can avoid the cumbersome ?:
in AstExpressionBuilder
. Instead there will be one method to visit single field relevance functions and another to visit multi-field relevance functions.
Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: Yury Fridlyand <[email protected]>
…hub.com/Bit-Quill/opensearch-project-sql into dev-simple_query_string-#192-sql-simple
Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
rejectMultipleStars test is failing right now. Run it only if WIP_TEST environment variable is set to something. Signed-off-by: MaxKsyunz <[email protected]>
It now only accepts ['*'] or ['*'] or a list of quoted identifiers. Skip a test for an existing bug in match implementation unless env variable GITHUB_ISSUE is set to 182 -- the ticket # it was added under. Signed-off-by: MaxKsyunz <[email protected]>
Closed as of #61. |
Description
SQL and PPL parser update to support
simple_query_string
, see opensearch-project#192Require #54 to support end-to-end flow.
TODO:
AstExpressionBuilder.java
x2Issues 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.