{"record":{"id":"f9e095e92b77afe5","repo":"apache/shardingsphere","slug":"42000-f9e095","errorCode":"42000","errorMessage":"You have an error in your SQL syntax: %s","messagePattern":"You have an error in your SQL syntax: (.+?)","errorType":"exception","errorClass":"SQLParsingException","httpStatus":null,"severity":"error","filePath":"parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementParserEngine.java","lineNumber":45,"sourceCode":"/**\n * SQL statement parser engine for kernel DistSQL.\n */\npublic final class KernelDistSQLStatementParserEngine {\n    \n    /**\n     * Parse SQL.\n     *\n     * @param sql SQL to be parsed\n     * @return SQL statement\n     */\n    public SQLStatement parse(final String sql) {\n        ASTNode astNode = SQLParserFactory.newInstance(sql, KernelDistSQLLexer.class, KernelDistSQLParser.class).parse();\n        return getSQLStatement(sql, (ParseASTNode) astNode);\n    }\n    \n    private SQLStatement getSQLStatement(final String sql, final ParseASTNode parseASTNode) {\n        if (parseASTNode.getRootNode() instanceof ErrorNode) {\n            throw new SQLParsingException(sql);\n        }\n        return (SQLStatement) (new KernelDistSQLStatementVisitor()).visit(parseASTNode.getRootNode());\n    }\n}\n","sourceCodeStart":27,"sourceCodeEnd":50,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/parser/distsql/engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/kernel/KernelDistSQLStatementParserEngine.java#L27-L50","documentation":"Thrown by KernelDistSQLStatementParserEngine.getSQLStatement when the kernel DistSQL parser (KernelDistSQLLexer/Parser) produces a ParseASTNode whose root is an ErrorNode. This engine handles kernel-level DistSQL (e.g. SHOW/DISTINCT VARIABLE, SET statements) in a single-phase parse, so any grammar-level failure that ANTLR recovers from surfaces here rather than as a cancellation.","triggerScenarios":"Calling KernelDistSQLStatementParserEngine.parse with malformed kernel DistSQL: 'SHOW VARIABLE' misspellings, invalid SET VARIABLE value syntax, unexpected trailing tokens, or a statement belonging to a feature facade routed to the kernel engine by mistake.","commonSituations":"Typing kernel DistSQL by hand in the proxy CLI; script-driven variable management with wrong value quoting; version drift where kernel grammar rules were renamed; routing logic sending feature DistSQL to the kernel engine.","solutions":["Match the statement exactly to kernel DistSQL grammar (SHOW DIST_VARIABLE / SET DIST_VARIABLE etc. for your version)","Fix quoting and value formats in SET statements","Route feature-specific statements to DistSQLParserEngine instead of the kernel engine","Consult KernelDistSQL.g4 grammar for the supported statement forms"],"exampleFix":"// before\nengine.parse(\"SET DIST_VARIABLES = a=1\"); // wrong keyword form\n\n// after\nengine.parse(\"SET DIST VARIABLE a=1\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    SQLStatement stmt = kernelEngine.parse(distSql);\n} catch (SQLParsingException e) {\n    // reject and show user the offending statement\n}","preventionTips":["Use exact kernel DistSQL forms (SHOW DIST_VARIABLE, SET DIST VARIABLE) for your version","Keep variable-management scripts in one place and lint their keywords","Don't route feature DistSQL to the kernel engine"],"tags":["distsql","kernel","parser","syntax","antlr"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}