zhisheng17/flink-learning · error · SqlParserException
Unsupported command '{}'
Error message
Unsupported command '{}' What it means
SqlCommandParser.parseLine throws SqlParserException when a semicolon-terminated statement cannot be parsed into a known SqlCommandCall. The parser matches the first keyword against a registry of supported SQL commands (INSERT INTO, CREATE TABLE, etc.); anything unrecognized — including empty statements or stray semicolons — fails. This is a fail-fast guard so invalid scripts abort before reaching the planner.
Source
Thrown at flink-learning-sql/flink-learning-sql-client/src/main/java/com/zhisheng/sql/cli/SqlCommandParser.java:28
public final class SqlCommandParser {
private SqlCommandParser() {
}
public static List<SqlCommandCall> parse(List<String> lines) {
List<SqlCommandCall> calls = new ArrayList<>();
StringBuilder stmt = new StringBuilder();
for (String line : lines) {
if (line.trim().isEmpty() || line.startsWith("--")) {
continue;
}
stmt.append("\n").append(line);
if (line.trim().endsWith(";")) {
Optional<SqlCommandCall> optionalCall = parse(stmt.toString());
if (optionalCall.isPresent()) {
calls.add(optionalCall.get());
} else {
throw new SqlParserException("Unsupported command '" + stmt.toString() + "'");
}
stmt.setLength(0);
}
}
return calls;
}
public static Optional<SqlCommandCall> parse(String stmt) {
stmt = stmt.trim();
if (stmt.endsWith(";")) {
stmt = stmt.substring(0, stmt.length() - 1).trim();
}
for (SqlCommand cmd : SqlCommand.values()) {
final Matcher matcher = cmd.pattern.matcher(stmt);
if (matcher.matches()) {
final String[] groups = new String[matcher.groupCount()];
for (int i = 0; i < groups.length; i++) {View on GitHub (pinned to d731cee761)
Solutions
- Fix the SQL statement to use a command registered in SqlCommand parser lookup (INSERT INTO, CREATE TABLE, CREATE FUNCTION, etc.)
- If you intended a SELECT query, wrap it as INSERT INTO <sink> SELECT ... or use EXPLAIN if supported
- Check for typos and stray semicolons in the statement before the failing ';'
- Extend the SqlCommand enum/parser registry to support the missing command type if it is a valid Flink SQL statement
Example fix
// before SELECT id, name FROM users; // after INSERT INTO print_sink SELECT id, name FROM users;
Defensive patterns
Strategy: validation
Validate before calling
String trimmed = stmt.trim();
if (trimmed.isEmpty() || !trimmed.matches("(?i)(INSERT\\s+INTO|CREATE\\s+(TABLE|FUNCTION)|EXPLAIN)\\b.*")) {
throw new IllegalArgumentException("Statement not supported by parser: " + stmt);
} Try / catch
try {
Optional<SqlCommandCall> call = parse(stmt);
call.ifPresent(calls::add);
} catch (SqlParserException e) {
LOG.error("Skipping unsupported statement: {}", stmt, e);
} Prevention
- Validate each statement's leading keyword before submitting a script
- Wrap ad-hoc SELECT queries as INSERT INTO <sink> statements
- Lint SQL scripts for typos and stray semicolons in CI
When it happens
Trigger: Calling SqlCommandParser.parse (via parseLine) with a statement whose leading keyword is not a registered SqlCommand, e.g. a bare 'SELECT 1;' (no INSERT/EXPLAIN wrapper), a typo like 'CREAT TABLE ...;', or an empty/whitespace-only statement ending with ';'.
Common situations: Running a SQL script file through the sql-client that contains plain SELECT queries the parser doesn't support, comments or SET syntax mis-handled by a custom client, or copy-pasted SQL with typos in DDL/DML keywords.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SQL parse failed: {}
- Unsupported command: {}
- invalid elasticsearch hosts format
- invalid elasticsearch hosts format
- Unsupported client type - cannot happen
AI-assisted analysis of zhisheng17/flink-learning@d731cee761 (2026-09-06).
Data as JSON: /api/errors/baeab4253a311b48.
Report an issue: GitHub.