apache/seatunnel · error · org.apache.seatunnel.api.table.catalog.exception.CatalogException

create partition error

Error message

create partition error

What it means

MaxComputeCatalog.createPartition calls odpsTable.createPartition(partitionSpec, true) and wraps any Exception in a CatalogException with this message. Creating the partition on the MaxCompute table failed at the SDK level.

Source

Thrown at seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/catalog/MaxComputeCatalog.java:268

                PartitionSpec partitionSpec =
                        new PartitionSpec(readonlyConfig.get(MaxcomputeBaseOptions.PARTITION_SPEC));
                odpsTable.deletePartition(partitionSpec, ignoreIfNotExists);
                odpsTable.createPartition(partitionSpec, true);
            } else {
                odpsTable.truncate();
            }
        } catch (Exception e) {
            throw new CatalogException("truncate table error", e);
        }
    }

    public void createPartition(TablePath tablePath, PartitionSpec partitionSpec) {
        try {
            Odps odps = getOdps(tablePath.getDatabaseName(), tablePath.getSchemaName());
            Table odpsTable = odps.tables().get(tablePath.getTableName());
            odpsTable.createPartition(partitionSpec, true);
        } catch (Exception e) {
            throw new CatalogException("create partition error", e);
        }
    }

    public void truncatePartition(TablePath tablePath, PartitionSpec partitionSpec) {
        try {
            Odps odps = getOdps(tablePath.getDatabaseName(), tablePath.getSchemaName());
            Table odpsTable = odps.tables().get(tablePath.getTableName());
            odpsTable.deletePartition(partitionSpec, true);
            odpsTable.createPartition(partitionSpec, true);
        } catch (Exception e) {
            throw new CatalogException("create partition error", e);
        }
    }

    @Override
    public boolean isExistsData(TablePath tablePath) {
        throw new UnsupportedOperationException();
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect the cause exception for the exact SDK error
  2. Verify the PartitionSpec matches the table's declared partition columns and format (key='value' pairs)
  3. Confirm the table exists and is partitioned (describe table in odpscmd)
  4. Grant Alter permission on the table to the configured account

Example fix

// before
PartitionSpec spec = new PartitionSpec("date=2024-01-01"); // wrong column name
odpsTable.createPartition(spec, true); // wrapped: create partition error
// after
PartitionSpec spec = new PartitionSpec("ds='2024-01-01'"); // matches table schema
odpsTable.createPartition(spec, true);
Defensive patterns

Strategy: validation

Validate before calling

// validate partition spec format before calling
String specStr = "ds='2024-01-01'"; // must match table partition columns
if (!specStr.matches("([a-zA-Z_][a-zA-Z0-9_]*='[^']*')(,\\s*([a-zA-Z_][a-zA-Z0-9_]*='[^']*'))*")) {
    throw new IllegalArgumentException("Invalid PartitionSpec format: " + specStr);
}

Try / catch

try {
    catalog.createPartition(tablePath, partitionSpec);
} catch (CatalogException e) {
    if (e.getCause() instanceof OdpsException
            && String.valueOf(e.getCause().getMessage()).toLowerCase().contains("not partitioned")) {
        throw new IllegalStateException("Table " + tablePath + " is not partitioned", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: createPartition resolves the table via getOdps(database, schema) and odps.tables().get(tableName); createPartition throws because the table is not partitioned, the spec is invalid, the table doesn't exist, or permissions are missing.

Common situations: Partition column names/values don't match the table's partition schema; target table is a non-partitioned table; table name typo or table missing; account lacks Alter permission; network/auth failures.

Related errors


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