Skip to content
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

[BUG] match function allows any constant as field name. #613

Closed
MaxKsyunz opened this issue May 18, 2022 · 7 comments
Closed

[BUG] match function allows any constant as field name. #613

MaxKsyunz opened this issue May 18, 2022 · 7 comments
Labels
bug Something isn't working legacy Issues related to legacy query engine to be deprecated SQL

Comments

@MaxKsyunz
Copy link
Collaborator

MaxKsyunz commented May 18, 2022

What is the bug?
The following queries are accepted by the SQL endpoint:
SELECT * FROM index WHERE MATCH(-3.14, "query")
SELECT * FROM index WHERE MATCH(interval 3 second, "query")

PPL endpoint is equally permissive.

What is the expected behavior?
SQL and PPL engines should only accept valid identifiers as field parameter of MATCH.

If the specified field does not exist, the user should receive the same error as they would if the field was used in SELECT clause.

This should be consistent across all single-field query functions described in #182.

@MaxKsyunz MaxKsyunz added bug Something isn't working untriaged labels May 18, 2022
@dai-chen
Copy link
Collaborator

dai-chen commented Aug 9, 2022

Wondering if this is already fixed in latest support for MATCH in SQL engine v2?

@Yury-Fridlyand
Copy link
Collaborator

Just tested on one of the latest builds:

opensearchsql> SELECT * FROM calcs WHERE MATCH(-3.14, "query");
{'reason': 'Invalid SQL query', 'details': 'syntax error, expect AGAINST, actual EOF', 'type': 'ParserException'}

@dai-chen
Copy link
Collaborator

dai-chen commented Aug 9, 2022

Just tested on one of the latest builds:

opensearchsql> SELECT * FROM calcs WHERE MATCH(-3.14, "query");
{'reason': 'Invalid SQL query', 'details': 'syntax error, expect AGAINST, actual EOF', 'type': 'ParserException'}

Thanks for the quick test! The query is rejected now but the syntax error seems unexpected? Or is just the message not accurate?

@Yury-Fridlyand
Copy link
Collaborator

The error comes from parser (ANTLR).
Actually, it fails on V2 engine, then in V1 and this error comes from V1.
The error aggregation and reporting is reworked in scope of #691. The error itself remains the same and it is not too verbose.

@dai-chen
Copy link
Collaborator

The error comes from parser (ANTLR). Actually, it fails on V2 engine, then in V1 and this error comes from V1. The error aggregation and reporting is reworked in scope of #691. The error itself remains the same and it is not too verbose.

I see. Probably because only identifier is allowed as first argument in v2, it fallback to legacy. This may go away when legacy is deprecated. Thanks

@dai-chen
Copy link
Collaborator

Can we close this now?

@forestmvey
Copy link
Collaborator

Can we close this now?

Yes this was fixed under #1067.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working legacy Issues related to legacy query engine to be deprecated SQL
Projects
No open projects
Status: Done
Development

No branches or pull requests

5 participants