Skip to content

Update for SQL and PPL parser to accept simple_query_string - #53

Closed
Yury-Fridlyand wants to merge 10 commits into
dev-simple_query_string-#192from
dev-simple_query_string-#192-sql-simple
Closed

Yury-Fridlyand wants to merge 10 commits into
dev-simple_query_string-#192from
dev-simple_query_string-#192-sql-simple

Conversation

@Yury-Fridlyand

@Yury-Fridlyand Yury-Fridlyand commented May 12, 2022 •

Copy link
Copy Markdown

Description

SQL and PPL parser update to support simple_query_string, see opensearch-project#192
Require #54 to support end-to-end flow.

TODO:

  • tests
  • rework on AstExpressionBuilder.java x2

Issues Resolved

^

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.

@Yury-Fridlyand Yury-Fridlyand mentioned this pull request May 12, 2022
1 of 6 tasks
@Yury-Fridlyand
Yury-Fridlyand requested a review from a team May 12, 2022 18:27
field=relevanceArgValue COMMA query=relevanceArgValue
field=relevanceField COMMA query=relevanceQuery
(COMMA relevanceArg)* RT_PRTHS
| relevanceFunctionNameEx LT_PRTHS

Copy link
Copy Markdown
Author

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.

Copy link
Copy Markdown

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.

Copy link
Copy Markdown

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.

Comment on lines 335 to 345
// 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(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  1. Should we create 2 different functions as relevanceArguments?
  2. Should we skip StringUtils.unquoteText for fields?

@MaxKsyunz

Copy link
Copy Markdown

Could you please make the SQL Java CI actions pass?

Signed-off-by: Yury Fridlyand <[email protected]>
@Yury-Fridlyand

Copy link
Copy Markdown
Author

Could you please make the SQL Java CI actions pass?

dc75ce8 fixes code style, rest failures require tests.

// to skip environment resolving and function signature resolving
ImmutableList.Builder<UnresolvedExpression> builder = ImmutableList.builder();
ParserRuleContext field = ctx.field;
if (field == null) {

Copy link
Copy Markdown

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;

DOT: '.';
LR_BRACKET: '(';
RR_BRACKET: ')';
LT_SQR_PRTHS: '[';

Copy link
Copy Markdown

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


@Override
public UnresolvedExpression visitRelevanceFunction(RelevanceFunctionContext ctx) {
ParserRuleContext func = ctx.relevanceFunctionNameEx();

@acarbonetto acarbonetto May 12, 2022 •

Copy link
Copy Markdown

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();

// 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;

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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.

MaxKsyunz and others added 7 commits May 13, 2022 14:40
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]>
@Yury-Fridlyand

Copy link
Copy Markdown
Author

Closed as of #61.

@Yury-Fridlyand
Yury-Fridlyand deleted the dev-simple_query_string-#192-sql-simple branch May 31, 2022 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants