{"record":{"id":"87df3ccecb6620a3","repo":"zhisheng17/flink-learning","slug":"sql-parse-failed","errorCode":null,"errorMessage":"SQL parse failed:\n{}\n","messagePattern":"SQL parse failed:\n(.+?)\n","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-learning-sql/flink-learning-sql-client/src/main/java/com/zhisheng/sql/planner/Planner.java","lineNumber":133,"sourceCode":"                case d:\n                    tEnv.getConfig().setIdleStateRetention(Duration.ofDays(Long.parseLong(number)));\n                    break;\n                default:\n                    break;\n            }\n\n        } else {\n            tEnv.getConfig().getConfiguration().setString(key, value);\n        }\n    }\n\n\n    private void callUpdate(SqlCommandParser.SqlCommandCall cmdCall) {\n        String ddl = cmdCall.operands[0];\n        try {\n            tEnv.executeSql(ddl);\n        } catch (SqlParserException e) {\n            throw new RuntimeException(\"SQL parse failed:\\n\" + ddl + \"\\n\", e);\n        }\n    }\n\n    private void explain(SqlCommandParser.SqlCommandCall cmdCall) {\n        String ddl = cmdCall.operands[0];\n        try {\n            this.isExplain = true;\n            tEnv.executeSql(ddl).print();\n        } catch (SqlParserException e) {\n            throw new RuntimeException(\"SQL parse failed:\\n\" + ddl + \"\\n\", e);\n        }\n    }\n\n    private void callCreateFunction(SqlCommandParser.SqlCommandCall cmdCall) {\n        LOG.info(\"create function:\" + cmdCall.operands[0]);\n        String ddl = cmdCall.operands[0];\n        try {\n            tEnv.executeSql(ddl);","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-sql/flink-learning-sql-client/src/main/java/com/zhisheng/sql/planner/Planner.java#L115-L151","documentation":"Planner.callUpdate executes a DDL/DML statement via tEnv.executeSql and wraps any SqlParserException in a RuntimeException that echoes the failing SQL. This distinguishes statement-parse failures from other execution errors so the user sees exactly which SQL text was rejected by the Flink SQL parser. It surfaces when DDL submitted for update (e.g. CREATE TABLE, ALTER) has invalid syntax or references unknown identifiers at parse time.","triggerScenarios":"callCommand routes a command to callUpdate, and tEnv.executeSql(ddl) throws SqlParserException because the statement's syntax is invalid or references unresolvable identifiers at parse time.","commonSituations":"Malformed CREATE TABLE statements (missing WITH clause connectors, bad data types), wrong catalog/database identifiers, or SQL dialect mismatches (Hive/Calcite syntax not supported by the current parser).","solutions":["Fix the SQL syntax in the failing statement shown in the exception message","Validate connector options and data types against the Flink version's supported SQL grammar","Test the statement in a SQL client / Flink SQL gateway to confirm it parses","Catch SqlParserException at a higher level to log the failing DDL and continue with remaining statements if batch processing is desired"],"exampleFix":"// before\ntEnv.executeSql(\"CREATE TABLE t (id STRING) WITH ('connector'='foo')\");\n// after\ntEnv.executeSql(\"CREATE TABLE t (id STRING) WITH ('connector'='kafka', 'topic'='t', 'properties.bootstrap.servers'='localhost:9092', 'format'='json')\");","handlingStrategy":"try-catch","validationCode":"// sanity check before executeSql\nif (ddl == null || ddl.trim().isEmpty()) throw new IllegalArgumentException(\"Empty DDL statement\");","typeGuard":null,"tryCatchPattern":"try {\n    tEnv.executeSql(ddl);\n} catch (SqlParserException e) {\n    LOG.error(\"Invalid DDL:\\n{}\\nCause: {}\", ddl, e.getMessage());\n    throw e;\n}","preventionTips":["Validate DDL in a dev SQL client before deploying scripts","Pin SQL dialect/connector options to your exact Flink version","Keep DDL in reviewed files rather than string-concatenated at runtime"],"tags":["sql","parser","flink","ddl"],"backgroundTag":"sql-query-failed","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}