- Newest
- Most votes
- Most comments
According to https://docs.aws.amazon.com/athena/latest/ug/reserved-words.html the quoting style is different for DDL statements like ALTER TABLE. Specifically, while SELECT statements use double-quotes ("), DDL statements use backticks (`).
So it would be:
ALTER TABLE `catalog`.`database`.`table` SET TBLPROPERTIES ('key'='value');
and:
SELECT COUNT(*) FROM "catalog"."database"."table"
answered a year ago
Thank you for reporting this issue. You're correct that there appears to be unexpected behavior with the ALTER TABLE statement in Amazon Athena when using quoted identifiers.
The behavior you're experiencing where the ALTER TABLE statement fails with quoted identifiers, but SELECT works fine, is indeed inconsistent. This seems to be a limitation or bug in Athena's SQL parser for DDL statements.
As a workaround, you can try using the ALTER TABLE statement without quotes around the identifiers:
ALTER TABLE catalog.database.table SET TBLPROPERTIES ('key'='value');
If you need to use identifiers that contain special characters or spaces, which would normally require quoting, you may need to consider renaming those objects to use simpler names that don't require quotes.
It's worth noting that Athena has some limitations and unsupported DDL operations. While ALTER TABLE SET TBLPROPERTIES is generally supported, the specific syntax with quoted identifiers appears to be problematic.
If this workaround doesn't resolve your issue, or if you absolutely need to use quoted identifiers in your ALTER TABLE statements, I recommend contacting AWS support to report this as a potential bug. They can provide more specific guidance or potentially address this in a future update to Athena.
Sources
Unsupported DDL - Amazon Athena
Relevant content
- AWS OFFICIALUpdated 2 years ago
