This is an automated email from the ASF dual-hosted git repository. snuyanzin pushed a commit to branch release-1.17 in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.17 by this push: new 05f207cab63 [FLINK-31142][Table SQL/Client] Catch TokenMgrError in SqlCommandParserImpl#scan 05f207cab63 is described below commit 05f207cab637f46709feb9986b137456ecbe5b7a Author: Sergey Nuyanzin <snuyan...@gmail.com> AuthorDate: Sun Feb 26 14:58:09 2023 +0100 [FLINK-31142][Table SQL/Client] Catch TokenMgrError in SqlCommandParserImpl#scan --- .../flink/table/client/cli/parser/SqlCommandParserImpl.java | 8 +++++++- flink-table/flink-sql-client/src/test/resources/sql/select.q | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/parser/SqlCommandParserImpl.java b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/parser/SqlCommandParserImpl.java index 9f3921110fb..017b27f45f4 100644 --- a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/parser/SqlCommandParserImpl.java +++ b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/parser/SqlCommandParserImpl.java @@ -21,6 +21,7 @@ package org.apache.flink.table.client.cli.parser; import org.apache.flink.sql.parser.impl.FlinkSqlParserImplTokenManager; import org.apache.flink.sql.parser.impl.SimpleCharStream; import org.apache.flink.sql.parser.impl.Token; +import org.apache.flink.sql.parser.impl.TokenMgrError; import org.apache.flink.table.api.SqlParserEOFException; import org.apache.flink.table.client.gateway.SqlExecutionException; @@ -86,7 +87,12 @@ public class SqlCommandParserImpl implements SqlCommandParser { Token current = currentToken; while (pos-- > 0) { if (current.next == null) { - current.next = tokenManager.getNextToken(); + try { + current.next = tokenManager.getNextToken(); + } catch (TokenMgrError tme) { + throw new SqlExecutionException( + "SQL parse failed. " + tme.getMessage(), tme); + } } current = current.next; } diff --git a/flink-table/flink-sql-client/src/test/resources/sql/select.q b/flink-table/flink-sql-client/src/test/resources/sql/select.q index 99f9e047834..29f4f8bed22 100644 --- a/flink-table/flink-sql-client/src/test/resources/sql/select.q +++ b/flink-table/flink-sql-client/src/test/resources/sql/select.q @@ -230,3 +230,8 @@ SELECT INTERVAL '1' DAY as dayInterval, INTERVAL '1' YEAR as yearInterval; +-----------------+--------------+ 1 row in set !ok + +SELECT /*; +[ERROR] Could not execute SQL statement. Reason: +org.apache.flink.sql.parser.impl.TokenMgrError: Lexical error at line 1, column 11. Encountered: <EOF> after : "" +!error