{"record":{"id":"0f3492872c019bcd","repo":"apache/seatunnel","slug":"sql-syntax-error-in-sql-transform-targetexcepti","errorCode":null,"errorMessage":"SQL Syntax Error in Sql Transform: ${targetException.message}","messagePattern":"SQL Syntax Error in Sql Transform: (.+?)","errorType":"validation","errorClass":"ConfigCheckException","httpStatus":null,"severity":"error","filePath":"seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java","lineNumber":353,"sourceCode":"            throws ConfigCheckException {\n        if (!pluginConfig.hasPath(\"query\")) {\n            return;\n        }\n\n        String query = pluginConfig.getString(\"query\");\n        if (StringUtils.isBlank(query)) {\n            return;\n        }\n\n        try {\n            Class<?> parserUtilClass =\n                    Class.forName(\n                            \"net.sf.jsqlparser.parser.CCJSqlParserUtil\", true, pluginClassLoader);\n            Method parseMethod = parserUtilClass.getMethod(\"parse\", String.class);\n            parseMethod.invoke(null, query);\n            log.debug(\"Successfully validated SQL transform syntax statically.\");\n        } catch (InvocationTargetException e) {\n            throw new ConfigCheckException(\n                    \"SQL Syntax Error in Sql Transform: \" + e.getTargetException().getMessage(),\n                    e.getTargetException());\n        } catch (Exception e) {\n            log.warn(\"Could not dynamically load JSqlParser for strict SQL syntax validation\", e);\n        }\n    }\n}\n","sourceCodeStart":335,"sourceCodeEnd":361,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java#L335-L361","documentation":"For Sql transform plugin blocks, SeaTunnelConfValidateCommand statically checks SQL syntax by reflectively loading JSqlParser (CCJSqlParserUtil) through the plugin classloader and parsing the `query`. If JSqlParser parses the SQL and throws, the underlying parser message is rethrown as a ConfigCheckException. Non-parse failures (e.g. JSqlParser not on the classpath) are only logged as warnings, so this error specifically means the SQL itself is malformed.","triggerScenarios":"A Sql transform config contains a `query` whose SQL fails JSqlParser parsing during `--validate`; the InvocationTargetException from the reflective parse call is unwrapped and rethrown.","commonSituations":"Typos in SQL keywords, missing FROM clauses, dangling commas, dialect-specific syntax JSqlParser does not understand, quotes/backticks mismatched, or SQL split incorrectly across HOCON string concatenation.","solutions":["Fix the SQL reported after 'SQL Syntax Error in Sql Transform:' — the wrapped message points at the parser failure position","Paste the query into a standalone SQL parser (or the target DB) to confirm valid syntax","Check HOCON quoting so the full query string reaches the transform intact (multi-line strings with triple quotes)","Verify the SeaTunnel version's bundled JSqlParser supports the SQL dialect used"],"exampleFix":"// before\ntransform {\n  Sql {\n    source_table_name = \"fake\"\n    result_table_name = \"out\"\n    query = \"select id, name form fake\"\n  }\n}\n// after\ntransform {\n  Sql {\n    source_table_name = \"fake\"\n    result_table_name = \"out\"\n    query = \"select id, name from fake\"\n  }\n}","handlingStrategy":"validation","validationCode":"// Validate SQL locally before putting it in config\nString sql = \"select id, name from fake\";\ntry {\n    net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(sql);\n} catch (Exception e) {\n    throw new IllegalArgumentException(\"Invalid transform SQL: \" + e.getMessage());\n}","typeGuard":null,"tryCatchPattern":"try {\n    command.execute(args);\n} catch (ConfigCheckException e) {\n    if (e.getMessage().startsWith(\"SQL Syntax Error\")) {\n        log.error(\"Fix transform query: {}\", e.getMessage());\n    }\n}","preventionTips":["Test transform SQL in a standalone JSqlParser or DB client first","Use HOCON triple-quoted strings for multi-line SQL","Avoid dialect features unsupported by JSqlParser","Keep SQL on review in PRs to catch typos like form/from"],"tags":["sql","syntax-error","transform","static-validation"],"backgroundTag":"sql-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}