{"record":{"id":"28bd2f97fa4df05d","repo":"apache/seatunnel","slug":"the-source-table-s-is-not-found","errorCode":null,"errorMessage":"The source table[%s] is not found","messagePattern":"The source table\\[(.+?)\\] is not found","errorType":"exception","errorClass":"ParserException","httpStatus":null,"severity":"error","filePath":"seatunnel-config/seatunnel-config-sql/src/main/java/org/apache/seatunnel/config/sql/SqlConfigBuilder.java","lineNumber":336,"sourceCode":"                    if (!(trimVal.startsWith(\"{\") && trimVal.endsWith(\"}\"))\n                            && !(trimVal.startsWith(\"[\") && trimVal.endsWith(\"]\"))) {\n                        v = \"\\\"\" + v + \"\\\"\";\n                    }\n                    Option option = Option.of(k, v);\n                    optionList.add(option);\n                });\n    }\n\n    private static TransformConfig parseCreateAsSql(\n            CreateTable createTable, Map<String, BaseConfig> sqlTables) {\n        Select select = createTable.getSelect();\n        if (select != null) {\n            TransformConfig transformConfig = new TransformConfig();\n            PlainSelect plainSelect = (PlainSelect) select.getSelectBody();\n            Table table = (Table) plainSelect.getFromItem();\n            String pluginInputIdentifier = table.getName();\n            if (!sqlTables.containsKey(pluginInputIdentifier)) {\n                throw new ParserException(\n                        String.format(\"The source table[%s] is not found\", pluginInputIdentifier));\n            }\n\n            String pluginOutputIdentifier = createTable.getTable().getName();\n            if (sqlTables.containsKey(pluginOutputIdentifier)) {\n                throw new ParserException(\n                        String.format(\"Table name duplicate: %s\", pluginOutputIdentifier));\n            }\n            sqlTables.put(pluginOutputIdentifier, transformConfig);\n\n            String query = select.toString();\n            transformConfig.setPluginInputIdentifier(pluginInputIdentifier);\n            transformConfig.setPluginOutputIdentifier(pluginOutputIdentifier);\n            transformConfig.setQuery(query);\n\n            return transformConfig;\n        } else {\n            throw new ParserException(String.format(\"Unsupported syntax: %s\", createTable));","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-config/seatunnel-config-sql/src/main/java/org/apache/seatunnel/config/sql/SqlConfigBuilder.java#L318-L354","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Declare the source table with CREATE TABLE t1 WITH ('connector'=...,'table_type'='source') before the CTAS statement","Fix the FROM identifier to match the earlier declared table name exactly","Move the CREATE TABLE ... AS SELECT after the source table definition in the script"],"exampleFix":"// before\nCREATE TABLE t2 AS SELECT * FROM t1 -- t1 undeclared\n// after\nCREATE TABLE t1 WITH ('connector'='fake','table_type'='source');\nCREATE TABLE t2 AS SELECT * FROM t1","handlingStrategy":"validation","validationCode":"// before the CTAS, verify source exists\ncollectDeclaredTables(sql) // parse all CREATE TABLE names first\nif (!declaredTables.contains(fromTableName)) {\n    throw new IllegalArgumentException(\"FROM table \" + fromTableName + \" must be declared before CREATE TABLE ... AS SELECT\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    SeaTunnelConfig c = SqlConfigBuilder.of(sql);\n} catch (ParserException e) {\n    if (e.getMessage().startsWith(\"The source table[\")) {\n        String tbl = extractBetween(e.getMessage(), \"[\", \"]\");\n        // check declaration order / spelling of tbl\n    }\n}","preventionTips":["Declare all source tables at the top of the SQL script before any CTAS","Match table name identifiers exactly (case-sensitive)","Keep statements in dependency order: source -> transform (CTAS) -> sink + INSERT"],"tags":["sql","config","parser","unknown-table"],"backgroundTag":"resource-not-found","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"}