apache/seatunnel · error · ConfigCheckException

SQL Syntax Error in Sql Transform: ${targetException.message

Error message

SQL Syntax Error in Sql Transform: ${targetException.message}

What it means

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.

Source

Thrown at seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java:353

            throws ConfigCheckException {
        if (!pluginConfig.hasPath("query")) {
            return;
        }

        String query = pluginConfig.getString("query");
        if (StringUtils.isBlank(query)) {
            return;
        }

        try {
            Class<?> parserUtilClass =
                    Class.forName(
                            "net.sf.jsqlparser.parser.CCJSqlParserUtil", true, pluginClassLoader);
            Method parseMethod = parserUtilClass.getMethod("parse", String.class);
            parseMethod.invoke(null, query);
            log.debug("Successfully validated SQL transform syntax statically.");
        } catch (InvocationTargetException e) {
            throw new ConfigCheckException(
                    "SQL Syntax Error in Sql Transform: " + e.getTargetException().getMessage(),
                    e.getTargetException());
        } catch (Exception e) {
            log.warn("Could not dynamically load JSqlParser for strict SQL syntax validation", e);
        }
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Fix the SQL reported after 'SQL Syntax Error in Sql Transform:' — the wrapped message points at the parser failure position
  2. Paste the query into a standalone SQL parser (or the target DB) to confirm valid syntax
  3. Check HOCON quoting so the full query string reaches the transform intact (multi-line strings with triple quotes)
  4. Verify the SeaTunnel version's bundled JSqlParser supports the SQL dialect used

Example fix

// before
transform {
  Sql {
    source_table_name = "fake"
    result_table_name = "out"
    query = "select id, name form fake"
  }
}
// after
transform {
  Sql {
    source_table_name = "fake"
    result_table_name = "out"
    query = "select id, name from fake"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate SQL locally before putting it in config
String sql = "select id, name from fake";
try {
    net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(sql);
} catch (Exception e) {
    throw new IllegalArgumentException("Invalid transform SQL: " + e.getMessage());
}

Try / catch

try {
    command.execute(args);
} catch (ConfigCheckException e) {
    if (e.getMessage().startsWith("SQL Syntax Error")) {
        log.error("Fix transform query: {}", e.getMessage());
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/0f3492872c019bcd. Report an issue: GitHub.