{"record":{"id":"66d3e586affeae87","repo":"apache/seatunnel","slug":"create-partition-error","errorCode":null,"errorMessage":"create partition error","messagePattern":"create partition error","errorType":"exception","errorClass":"org.apache.seatunnel.api.table.catalog.exception.CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/catalog/MaxComputeCatalog.java","lineNumber":268,"sourceCode":"                PartitionSpec partitionSpec =\n                        new PartitionSpec(readonlyConfig.get(MaxcomputeBaseOptions.PARTITION_SPEC));\n                odpsTable.deletePartition(partitionSpec, ignoreIfNotExists);\n                odpsTable.createPartition(partitionSpec, true);\n            } else {\n                odpsTable.truncate();\n            }\n        } catch (Exception e) {\n            throw new CatalogException(\"truncate table error\", e);\n        }\n    }\n\n    public void createPartition(TablePath tablePath, PartitionSpec partitionSpec) {\n        try {\n            Odps odps = getOdps(tablePath.getDatabaseName(), tablePath.getSchemaName());\n            Table odpsTable = odps.tables().get(tablePath.getTableName());\n            odpsTable.createPartition(partitionSpec, true);\n        } catch (Exception e) {\n            throw new CatalogException(\"create partition error\", e);\n        }\n    }\n\n    public void truncatePartition(TablePath tablePath, PartitionSpec partitionSpec) {\n        try {\n            Odps odps = getOdps(tablePath.getDatabaseName(), tablePath.getSchemaName());\n            Table odpsTable = odps.tables().get(tablePath.getTableName());\n            odpsTable.deletePartition(partitionSpec, true);\n            odpsTable.createPartition(partitionSpec, true);\n        } catch (Exception e) {\n            throw new CatalogException(\"create partition error\", e);\n        }\n    }\n\n    @Override\n    public boolean isExistsData(TablePath tablePath) {\n        throw new UnsupportedOperationException();\n    }","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/catalog/MaxComputeCatalog.java#L250-L286","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the cause exception for the exact SDK error","Verify the PartitionSpec matches the table's declared partition columns and format (key='value' pairs)","Confirm the table exists and is partitioned (describe table in odpscmd)","Grant Alter permission on the table to the configured account"],"exampleFix":"// before\nPartitionSpec spec = new PartitionSpec(\"date=2024-01-01\"); // wrong column name\nodpsTable.createPartition(spec, true); // wrapped: create partition error\n// after\nPartitionSpec spec = new PartitionSpec(\"ds='2024-01-01'\"); // matches table schema\nodpsTable.createPartition(spec, true);","handlingStrategy":"validation","validationCode":"// validate partition spec format before calling\nString specStr = \"ds='2024-01-01'\"; // must match table partition columns\nif (!specStr.matches(\"([a-zA-Z_][a-zA-Z0-9_]*='[^']*')(,\\\\s*([a-zA-Z_][a-zA-Z0-9_]*='[^']*'))*\")) {\n    throw new IllegalArgumentException(\"Invalid PartitionSpec format: \" + specStr);\n}","typeGuard":null,"tryCatchPattern":"try {\n    catalog.createPartition(tablePath, partitionSpec);\n} catch (CatalogException e) {\n    if (e.getCause() instanceof OdpsException\n            && String.valueOf(e.getCause().getMessage()).toLowerCase().contains(\"not partitioned\")) {\n        throw new IllegalStateException(\"Table \" + tablePath + \" is not partitioned\", e);\n    }\n    throw e;\n}","preventionTips":["Match PartitionSpec keys/values exactly to the table's partition schema (key='value' format)","Skip partition creation for non-partitioned tables","Grant Alter permission on the table to the runtime account","Verify the table exists (tableExists) before creating partitions"],"tags":["maxcompute","catalog","partition","odps"],"backgroundTag":"database-write-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"}