- Newest
- Most votes
- Most comments
The issue you're encountering is related to how Athena handles hidden partitions in Iceberg tables when using the OPTIMIZE command. When you use hidden partitioning with a transform function like truncate, Athena doesn't directly expose these partitions in the same way as regular partitions.
For Iceberg tables with hidden partitioning, the OPTIMIZE command doesn't support filtering on the transformed partition columns directly. The WHERE clause in the OPTIMIZE command is meant to work with visible partition columns or data columns, not the hidden partition values created by transform functions.
To work around this limitation, you can try the following approach:
- Instead of using the transformed column in the WHERE clause, use the original column with a range that corresponds to the hidden partition you want to optimize. For example:
OPTIMIZE Table REWRITE DATA USING BIN_PACK
WHERE col1='value' AND col2 >= 169000 AND col2 < 170000
This will target the specific partition you're interested in (169000) without directly referencing the hidden partition column.
- If you need to optimize multiple specific partitions, you can use OR conditions to include them:
OPTIMIZE Table REWRITE DATA USING BIN_PACK
WHERE col1='value' AND
((col2 >= 169000 AND col2 < 170000) OR
(col2 >= 170000 AND col2 < 171000))
- If you need to optimize a large number of partitions, you might need to run multiple OPTIMIZE commands, each targeting a subset of partitions.
Remember that while this approach doesn't directly reference the hidden partition column, it should effectively target the data within the desired partitions. However, be aware that this method might not be as efficient as directly specifying partitions in tables with visible partitioning.
If you continue to experience issues or if this approach doesn't meet your needs, you may need to consider restructuring your table to use visible partitions instead of hidden partitions, or consult with AWS support for more specific guidance on optimizing Iceberg tables with hidden partitions in Athena.
Sources
Optimize Iceberg tables - Amazon Athena
Troubleshoot Athena Apache Iceberg table errors | AWS re:Post
Relevant content
asked a year ago
asked 2 years ago
- AWS OFFICIALUpdated 2 years ago

I tried running:
But still same error: GENERIC_INTERNAL_ERROR: Unexpected FilterNode found in plan; probably connector was not able to handle provided WHERE expression. simply running
works fine