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".

Resolution

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:

  1. Open the AWS Glue console.
  2. Choose the table name in the list, and then choose Edit schema.
  3. Choose Add column.
  4. Enter the column name, type, and number, and then check the Partition key box.
  5. Choose Add.

For more information, see Viewing and editing table details.


Did this article help?


Do you need billing or technical support?