apache/seatunnel · error · org.apache.seatunnel.api.table.catalog.exception.CatalogException
truncate table error
Error message
truncate table error
What it means
MaxComputeCatalog.truncateTable either deletes+recreates a partition or calls odpsTable.truncate(); any Exception is wrapped in a CatalogException with this message. Truncation failed at the SDK level (missing table, bad partition spec, permissions, or transient errors).
Source
Thrown at seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/catalog/MaxComputeCatalog.java:258
@Override
public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)
throws TableNotExistException, CatalogException {
try {
Odps odps = getOdps(tablePath.getDatabaseName(), tablePath.getSchemaName());
Table odpsTable = odps.tables().get(tablePath.getTableName());
if (odpsTable.isPartitioned()
&& StringUtils.isNotEmpty(
readonlyConfig.get(MaxcomputeBaseOptions.PARTITION_SPEC))) {
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);View on GitHub (pinned to cf67b549a7)
Solutions
- Check the cause exception for which SDK call failed
- Verify the partition spec column names/values exactly match the table's partition schema
- Confirm the table exists and the account has Alter/Write permissions
- Manually test the equivalent truncate/delete-partition via odpscmd
Example fix
// before
PartitionSpec spec = new PartitionSpec("ds='2024-01-01'");
catalog.truncateTable(TablePath.of("proj", "events"), spec); // table partitioned by ds,pt
// after
PartitionSpec spec = new PartitionSpec("ds='2024-01-01', pt='00'"); // full partition key
catalog.truncateTable(TablePath.of("proj", "events"), spec); Defensive patterns
Strategy: validation
Validate before calling
// verify partition spec matches the table's partition columns before truncating
Table odpsTable = odps.tables().get(tableName);
if (odpsTable.getPartitionColumnInfo().stream()
.noneMatch(c -> partitionSpec.keys().contains(c.getName()))) {
throw new IllegalArgumentException("PartitionSpec " + partitionSpec + " does not match table partition columns");
} Try / catch
try {
catalog.truncateTable(tablePath, partitionSpec);
} catch (CatalogException e) {
LOG.error("Truncate failed for " + tablePath + ", spec=" + partitionSpec, e);
throw e;
} Prevention
- Describe the table in odpscmd to confirm partition columns before building a PartitionSpec
- Confirm the account has Alter/Write permission on the table
- For non-partitioned tables, expect truncate() semantics and no PartitionSpec
- Wrap catalog mutations in save-mode checks to avoid operating on the wrong table
When it happens
Trigger: truncateTable resolves the odps table; for partitioned tables it calls deletePartition/createPartition with a PartitionSpec; otherwise odpsTable.truncate(). Any of these throws and is rethrown as 'truncate table error'.
Common situations: PartitionSpec does not match the table's partition columns; table not found (name/database mismatch); account lacks Alter permission on the table; truncate called on a table type that doesn't support it.
Related errors
- create partition error
- Failed to truncate BigQuery table:
- Truncate table failed
- Failed to truncate table ${tableName} in catalog ${catalogNa
- TABLE_NOT_EXISTED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/cc93f990271194dd.
Report an issue: GitHub.