{"record":{"id":"baeab4253a311b48","repo":"zhisheng17/flink-learning","slug":"unsupported-command","errorCode":null,"errorMessage":"Unsupported command '{}'","messagePattern":"Unsupported command '(.+?)'","errorType":"exception","errorClass":"SqlParserException","httpStatus":null,"severity":"error","filePath":"flink-learning-sql/flink-learning-sql-client/src/main/java/com/zhisheng/sql/cli/SqlCommandParser.java","lineNumber":28,"sourceCode":"public final class SqlCommandParser {\n\n    private SqlCommandParser() {\n    }\n\n    public static List<SqlCommandCall> parse(List<String> lines) {\n        List<SqlCommandCall> calls = new ArrayList<>();\n        StringBuilder stmt = new StringBuilder();\n        for (String line : lines) {\n            if (line.trim().isEmpty() || line.startsWith(\"--\")) {\n                continue;\n            }\n            stmt.append(\"\\n\").append(line);\n            if (line.trim().endsWith(\";\")) {\n                Optional<SqlCommandCall> optionalCall = parse(stmt.toString());\n                if (optionalCall.isPresent()) {\n                    calls.add(optionalCall.get());\n                } else {\n                    throw new SqlParserException(\"Unsupported command '\" + stmt.toString() + \"'\");\n                }\n                stmt.setLength(0);\n            }\n        }\n        return calls;\n    }\n\n    public static Optional<SqlCommandCall> parse(String stmt) {\n        stmt = stmt.trim();\n        if (stmt.endsWith(\";\")) {\n            stmt = stmt.substring(0, stmt.length() - 1).trim();\n        }\n\n        for (SqlCommand cmd : SqlCommand.values()) {\n            final Matcher matcher = cmd.pattern.matcher(stmt);\n            if (matcher.matches()) {\n                final String[] groups = new String[matcher.groupCount()];\n                for (int i = 0; i < groups.length; i++) {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-sql/flink-learning-sql-client/src/main/java/com/zhisheng/sql/cli/SqlCommandParser.java#L10-L46","documentation":"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.","triggerScenarios":"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 ';'.","commonSituations":"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.","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"],"exampleFix":"// before\nSELECT id, name FROM users;\n// after\nINSERT INTO print_sink SELECT id, name FROM users;","handlingStrategy":"validation","validationCode":"String trimmed = stmt.trim();\nif (trimmed.isEmpty() || !trimmed.matches(\"(?i)(INSERT\\\\s+INTO|CREATE\\\\s+(TABLE|FUNCTION)|EXPLAIN)\\\\b.*\")) {\n    throw new IllegalArgumentException(\"Statement not supported by parser: \" + stmt);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Optional<SqlCommandCall> call = parse(stmt);\n    call.ifPresent(calls::add);\n} catch (SqlParserException e) {\n    LOG.error(\"Skipping unsupported statement: {}\", stmt, e);\n}","preventionTips":["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"],"tags":["sql","parser","flink","sql-client"],"backgroundTag":"unsupported-operation","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}