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

Handle trailing semicolon in the SQL #17758

Open
FrankChen021 opened this issue Feb 26, 2025 · 0 comments
Open

Handle trailing semicolon in the SQL #17758

FrankChen021 opened this issue Feb 26, 2025 · 0 comments

Comments

@FrankChen021
Copy link
Member

for such SQL,

select 1;

The calcite report the following unfriendly error.

Suggestion: Remove trailing semicolon (;)

Error: INVALID_INPUT

Received an unexpected token [;] (line [1], column [9]), acceptable options: [<EOF>, "ORDER", "LIMIT", "OFFSET", "FETCH", "UNION", "INTERSECT", "EXCEPT", "MINUS", ",", "FROM", "AS", <IDENTIFIER>, <HYPHENATED_IDENTIFIER>, <QUOTED_IDENTIFIER>, <BACK_QUOTED_IDENTIFIER>, <BIG_QUERY_BACK_QUOTED_IDENTIFIER>, <BRACKET_QUOTED_IDENTIFIER>, <UNICODE_QUOTED_IDENTIFIER>, <QUOTED_STRING>, ".", "NOT", "IN", "<", "<=", ">", ">=", "=", "<>", "!=", "BETWEEN", "LIKE", "SIMILAR", "+", "-", "*", "/", "%", "||", "AND", "OR", "IS", "MEMBER", "SUBMULTISET", "CONTAINS", "OVERLAPS", "EQUALS", "PRECEDES", "SUCCEEDS", "MULTISET", "["]

It would be more friendly if we remove the semicolon from the SQL automatically instead of reporting an error. And because most of databases can ignore the semicolon if the input is a single statement, it's reasonable to do so.

To remove the trailing semicolon is not the perfect way, because for such input:

select 1;
select 2

Calcite report the same error too. So maybe we can remove the trailing semicolon first, and then catch the parse error, if such exception is raised, we should give a clear message saying that multiple statements is not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant