apache/seatunnel · error · ParserException

The source table[%s] is not found

Error message

The source table[%s] is not found

What it means

Thrown by parseCreateAsSql when the table referenced in the FROM clause of a CREATE TABLE ... AS SELECT statement is not a previously declared source/transform table. SQL config is built incrementally: every referenced table must have been created earlier in the same SQL script.

Source

Thrown at seatunnel-config/seatunnel-config-sql/src/main/java/org/apache/seatunnel/config/sql/SqlConfigBuilder.java:336

                    if (!(trimVal.startsWith("{") && trimVal.endsWith("}"))
                            && !(trimVal.startsWith("[") && trimVal.endsWith("]"))) {
                        v = "\"" + v + "\"";
                    }
                    Option option = Option.of(k, v);
                    optionList.add(option);
                });
    }

    private static TransformConfig parseCreateAsSql(
            CreateTable createTable, Map<String, BaseConfig> sqlTables) {
        Select select = createTable.getSelect();
        if (select != null) {
            TransformConfig transformConfig = new TransformConfig();
            PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
            Table table = (Table) plainSelect.getFromItem();
            String pluginInputIdentifier = table.getName();
            if (!sqlTables.containsKey(pluginInputIdentifier)) {
                throw new ParserException(
                        String.format("The source table[%s] is not found", pluginInputIdentifier));
            }

            String pluginOutputIdentifier = createTable.getTable().getName();
            if (sqlTables.containsKey(pluginOutputIdentifier)) {
                throw new ParserException(
                        String.format("Table name duplicate: %s", pluginOutputIdentifier));
            }
            sqlTables.put(pluginOutputIdentifier, transformConfig);

            String query = select.toString();
            transformConfig.setPluginInputIdentifier(pluginInputIdentifier);
            transformConfig.setPluginOutputIdentifier(pluginOutputIdentifier);
            transformConfig.setQuery(query);

            return transformConfig;
        } else {
            throw new ParserException(String.format("Unsupported syntax: %s", createTable));

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Declare the source table with CREATE TABLE t1 WITH ('connector'=...,'table_type'='source') before the CTAS statement
  2. Fix the FROM identifier to match the earlier declared table name exactly
  3. Move the CREATE TABLE ... AS SELECT after the source table definition in the script

Example fix

// before
CREATE TABLE t2 AS SELECT * FROM t1 -- t1 undeclared
// after
CREATE TABLE t1 WITH ('connector'='fake','table_type'='source');
CREATE TABLE t2 AS SELECT * FROM t1
Defensive patterns

Strategy: validation

Validate before calling

// before the CTAS, verify source exists
collectDeclaredTables(sql) // parse all CREATE TABLE names first
if (!declaredTables.contains(fromTableName)) {
    throw new IllegalArgumentException("FROM table " + fromTableName + " must be declared before CREATE TABLE ... AS SELECT");
}

Try / catch

try {
    SeaTunnelConfig c = SqlConfigBuilder.of(sql);
} catch (ParserException e) {
    if (e.getMessage().startsWith("The source table[")) {
        String tbl = extractBetween(e.getMessage(), "[", "]");
        // check declaration order / spelling of tbl
    }
}

Prevention

When it happens

Trigger: CREATE TABLE t2 AS SELECT ... FROM t1 where t1 was never declared via an earlier CREATE TABLE with 'connector'='xxx' and 'table_type'='source', or was declared under a different name (case-sensitive identifier).

Common situations: Typos in the FROM table name; missing the source CREATE TABLE statement; expecting auto-creation of sources from external catalogs; reordering statements so the source comes after the CTAS.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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