How can I troubleshoot the error "FAILED: SemanticException table is not partitioned but partition spec exists" in Athena?
Last updated: 2020-08-28
When I run ALTER TABLE ADD PARTITION in Amazon Athena, I get this error: "FAILED: SemanticException table is not partitioned but partition spec exists".
This error happens if you didn't define any partitions in the CREATE TABLE statement. To resolve this error, create the table again and use PARTITIONED BY to define the partition key. For an example, see Creating a table. After the partition is defined, you can use ALTER TABLE ADD PARTITION to add more partitions.
Or, edit the table schema in AWS Glue:
- Open the AWS Glue console.
- Choose the table name in the list, and then choose Edit schema.
- Choose Add column.
- Enter the column name, type, and number, and then check the Partition key box.
- Choose Add.
For more information, see Viewing and editing table details.