slinkydeveloper commented on a change in pull request #18363:
URL: https://github.com/apache/flink/pull/18363#discussion_r807968968
##########
File path:
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/parse/CalciteParser.java
##########
@@ -47,12 +49,36 @@ public CalciteParser(SqlParser.Config config) {
* @param sql a sql string to parse
* @return a parsed sql node
* @throws SqlParserException if an exception is thrown when parsing the
statement
+ * @throws SqlParserEOFException if the statement is incomplete
*/
public SqlNode parse(String sql) {
try {
SqlParser parser = SqlParser.create(sql, config);
return parser.parseStmt();
} catch (SqlParseException e) {
+ if (e.getMessage().contains("Encountered \"<EOF>\"")) {
+ throw new SqlParserEOFException(e.getMessage(), e);
+ }
+ throw new SqlParserException("SQL parse failed. " +
e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Parses a SQL string into a {@link SqlNodeList}. The {@link SqlNodeList}
is not yet validated.
+ *
+ * @param sql a sql string to parse
+ * @return a parsed sql node list
+ * @throws SqlParserException if an exception is thrown when parsing the
statement
+ * @throws SqlParserEOFException if the statement is incomplete
+ */
+ public SqlNodeList parseSqlList(String sql) {
+ try {
+ SqlParser parser = SqlParser.create(sql, config);
+ return parser.parseStmtList();
+ } catch (SqlParseException e) {
+ if (e.getMessage().contains("Encountered \"<EOF>\"")) {
+ throw new SqlParserEOFException(e.getMessage(), e);
Review comment:
What are the implications if we do this now vs later? Also look at this
point in particular:
https://cwiki.apache.org/confluence/display/FLINK/FLIP-189%3A+SQL+Client+Usability+Improvements#FLIP189:SQLClientUsabilityImprovements-ImplementationDetails
this talks about how in future we might want to extend `SqlMultiLineParser` to
catch more parsing errors to leverage other jline features. Having a single sub
exception for all of these is going to pollute our classpath.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]