apache/seatunnel · error · IllegalArgumentException

Can't find column in table.

Error message

Can't find column  in table.

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/util/CatalogUtil.java:156

            String col = columnInfo.getName();
            if (StringUtils.isEmpty(columnInfo.getInfo())) {
                if (columnMap.containsKey(col)) {
                    Column column = columnMap.get(col);
                    String newCol = columnToConnectorType(column);
                    String prefix = template.substring(0, columnInfo.getStartIndex() + offset);
                    String suffix = template.substring(offset + columnInfo.getEndIndex());
                    if (prefix.endsWith("`")) {
                        prefix = prefix.substring(0, prefix.length() - 1);
                        offset--;
                    }
                    if (suffix.startsWith("`")) {
                        suffix = suffix.substring(1);
                        offset--;
                    }
                    template = prefix + newCol + suffix;
                    offset += newCol.length() - columnInfo.getName().length();
                } else {
                    throw new IllegalArgumentException("Can't find column " + col + " in table.");
                }
            }
        }
        return template;
    }

    public String getDropDatabaseSql(String database, boolean ignoreIfNotExists) {
        if (ignoreIfNotExists) {
            return "DROP DATABASE IF EXISTS `" + database + "`";
        } else {
            return "DROP DATABASE `" + database + "`";
        }
    }

    public String getCreateDatabaseSql(String database, boolean ignoreIfExists) {
        if (ignoreIfExists) {
            return "CREATE DATABASE IF NOT EXISTS `" + database + "`";
        } else {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Align the template's column names with the actual SeaTunnel schema field names (exact spelling)
  2. Regenerate the template instead of hand-maintaining it, or remove the template option to use auto-generated DDL
  3. Log and diff schema field names vs template columns to spot the mismatch
  4. Add a pre-submit config validation that every template column exists in the schema

Example fix

// before
template = "CREATE TABLE t (id INT, nme STRING)"; // schema has "name"
// after
template = "CREATE TABLE t (id INT, name STRING)"; // matches schema field 'name'
Defensive patterns

Strategy: validation

Validate before calling

java
Set<String> schemaFields = new HashSet<>(Arrays.asList(rowType.getFieldNames()));
for (String col : templateColumns) {
    if (!schemaFields.contains(col)) throw new IllegalArgumentException("Column " + col + " missing from schema");
}

Try / catch

java
try {
    String sql = CatalogUtil.getCreateTableSql(...);
} catch (IllegalArgumentException e) {
    // log template vs schema fields, fix template
}

Prevention

When it happens

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

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

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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