{"record":{"id":"fe98d750a4470f16","repo":"apache/seatunnel","slug":"can-t-find-column-in-table","errorCode":null,"errorMessage":"Can't find column  in table.","messagePattern":"Can't find column  in table\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/util/CatalogUtil.java","lineNumber":156,"sourceCode":"            String col = columnInfo.getName();\n            if (StringUtils.isEmpty(columnInfo.getInfo())) {\n                if (columnMap.containsKey(col)) {\n                    Column column = columnMap.get(col);\n                    String newCol = columnToConnectorType(column);\n                    String prefix = template.substring(0, columnInfo.getStartIndex() + offset);\n                    String suffix = template.substring(offset + columnInfo.getEndIndex());\n                    if (prefix.endsWith(\"`\")) {\n                        prefix = prefix.substring(0, prefix.length() - 1);\n                        offset--;\n                    }\n                    if (suffix.startsWith(\"`\")) {\n                        suffix = suffix.substring(1);\n                        offset--;\n                    }\n                    template = prefix + newCol + suffix;\n                    offset += newCol.length() - columnInfo.getName().length();\n                } else {\n                    throw new IllegalArgumentException(\"Can't find column \" + col + \" in table.\");\n                }\n            }\n        }\n        return template;\n    }\n\n    public String getDropDatabaseSql(String database, boolean ignoreIfNotExists) {\n        if (ignoreIfNotExists) {\n            return \"DROP DATABASE IF EXISTS `\" + database + \"`\";\n        } else {\n            return \"DROP DATABASE `\" + database + \"`\";\n        }\n    }\n\n    public String getCreateDatabaseSql(String database, boolean ignoreIfExists) {\n        if (ignoreIfExists) {\n            return \"CREATE DATABASE IF NOT EXISTS `\" + database + \"`\";\n        } else {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/util/CatalogUtil.java#L138-L174","documentation":"mergeColumnInTemplate() rewrites column definitions inside a SQL DDL template by matching each template column name against the SeaTunnel schema. When a column referenced in the catalog-table template does not exist among the provided columns, it cannot locate the substring to replace and throws this IllegalArgumentException. This indicates the template and column list are inconsistent.","triggerScenarios":"Calling getCreateTableSql with a catalog table template containing a column name not present in the SeaTunnelRowType/columns passed in; case or whitespace mismatch between template column names and schema field names; template referencing a renamed/removed column.","commonSituations":"Users hand-write a 'template' option in a sink/source config whose DDL column list drifts from the schema (e.g. schema updated but template not); connector config with schema_transform that renames columns while template still has old names.","solutions":["Align the template's column names with the actual SeaTunnel schema field names (exact spelling)","Regenerate the template instead of hand-maintaining it, or remove the template option to use auto-generated DDL","Log and diff schema field names vs template columns to spot the mismatch","Add a pre-submit config validation that every template column exists in the schema"],"exampleFix":"// before\ntemplate = \"CREATE TABLE t (id INT, nme STRING)\"; // schema has \"name\"\n// after\ntemplate = \"CREATE TABLE t (id INT, name STRING)\"; // matches schema field 'name'","handlingStrategy":"validation","validationCode":"java\nSet<String> schemaFields = new HashSet<>(Arrays.asList(rowType.getFieldNames()));\nfor (String col : templateColumns) {\n    if (!schemaFields.contains(col)) throw new IllegalArgumentException(\"Column \" + col + \" missing from schema\");\n}","typeGuard":null,"tryCatchPattern":"java\ntry {\n    String sql = CatalogUtil.getCreateTableSql(...);\n} catch (IllegalArgumentException e) {\n    // log template vs schema fields, fix template\n}","preventionTips":["Generate templates from the schema instead of hand-writing","Re-verify template columns after any schema change","Use exact field-name casing from the schema"],"tags":["config-mismatch","ddl","template"],"backgroundTag":"schema-validation-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}