Search in sources :

Example 1 with SyntaxError

use of org.jline.reader.SyntaxError in project flink by apache.

the class SqlMultiLineParser method parse.

@Override
public ParsedLine parse(String line, int cursor, ParseContext context) {
    if (context != ParseContext.ACCEPT_LINE) {
        return parseInternal(line, cursor, context);
    }
    if (!line.trim().endsWith(STATEMENT_DELIMITER)) {
        throw new EOFError(-1, -1, "New line without EOF character.", NEW_LINE_PROMPT);
    }
    try {
        command = line;
        parseException = null;
        // try to parse the line read
        parsedOperation = parser.parseCommand(line).orElse(null);
    } catch (SqlExecutionException e) {
        if (e.getCause() instanceof SqlParserEOFException) {
            throw new EOFError(-1, -1, "The statement is incomplete.", NEW_LINE_PROMPT);
        }
        // cache the exception so that we can print details in the terminal.
        parseException = e;
        throw new SyntaxError(-1, -1, e.getMessage());
    }
    return parseInternal(line, cursor, context);
}
Also used : SqlExecutionException(org.apache.flink.table.client.gateway.SqlExecutionException) SyntaxError(org.jline.reader.SyntaxError) SqlParserEOFException(org.apache.flink.table.api.SqlParserEOFException) EOFError(org.jline.reader.EOFError)

Aggregations

SqlParserEOFException (org.apache.flink.table.api.SqlParserEOFException)1 SqlExecutionException (org.apache.flink.table.client.gateway.SqlExecutionException)1 EOFError (org.jline.reader.EOFError)1 SyntaxError (org.jline.reader.SyntaxError)1