Skip to content

QL: Introduce ParserUtils to consolidate code #76399

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

Merged
merged 1 commit into from
Aug 12, 2021

Conversation

costin
Copy link
Member

@costin costin commented Aug 12, 2021

Move common ANTLR utility methods, such as extracting code or case
insensitive streams into QL.
Replace CaseInsensitiveStream (which relies on ANTLRInputStream which
has been deprecated) with a CharStream variant.

@costin costin added >enhancement :Analytics/SQL SQL querying v8.0.0 :Analytics/EQL EQL querying auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) auto-backport Automatically create backport pull requests when merged v7.15.0 labels Aug 12, 2021
@costin costin requested a review from Luegg August 12, 2021 08:58
@elasticmachine elasticmachine added the Team:QL (Deprecated) Meta label for query languages team label Aug 12, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

Move common ANTLR utility methods, such as extracting code or case
insensitive streams into QL.
Replace CaseInsensitiveStream (which relies on ANTLRInputStream which
has been deprecated) with a CharStream variant.
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
7.x

costin added a commit that referenced this pull request Aug 12, 2021
Move common ANTLR utility methods, such as extracting code or case
insensitive streams into QL.
Replace CaseInsensitiveStream (which relies on ANTLRInputStream which
has been deprecated) with a CharStream variant.
Copy link
Contributor

@Luegg Luegg left a comment

Choose a reason for hiding this comment

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

Only minor comments, lgtm 👍

throw new ParsingException(source(ctx), "Invalid query '{}'[{}] given; expected {} but found {}",
ctx.getText(), ctx.getClass().getSimpleName(),
type.getSimpleName(), (result != null ? result.getClass().getSimpleName() : "null"));
return ParserUtils.typedParsing(this, ctx, type);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could typedParsing also be removed from AbstractBuilder and all usage replaced by ParserUtils.typedParsing (same as for visitList)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Raised #76418

* @param stream The stream to wrap.
* @param upper If true force each symbol to upper case, otherwise force to lower.
*/
public CaseChangingCharStream(CharStream stream, boolean upper) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a use case for upper = false for us?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not at the moment. The class has been copied from ANTLR. Since the bool is a final variable, I expect the JIT to optimize this code nicely.

costin added a commit to costin/elasticsearch that referenced this pull request Aug 12, 2021
Remove typedParsing method in favor of ParserUtils

Follow-up to elastic#76399
elasticsearchmachine pushed a commit that referenced this pull request Aug 12, 2021
Remove typedParsing method in favor of ParserUtils

Follow-up to #76399
elasticsearchmachine pushed a commit that referenced this pull request Aug 12, 2021
Remove typedParsing method in favor of ParserUtils

Follow-up to #76399
@costin costin deleted the ql/ql-parsing-utils branch August 12, 2021 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/EQL EQL querying :Analytics/SQL SQL querying auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >enhancement Team:QL (Deprecated) Meta label for query languages team v7.15.0 v8.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants