- Newest
- Most votes
- Most comments
The issue you're encountering appears to be related to how Athena handles complex data types like arrays when creating views on Iceberg tables. This is likely due to a mismatch in how the data type is interpreted between the Iceberg table format and Athena's view creation process.
To work around this issue, you can try explicitly casting the array column in your view definition. Instead of directly selecting the 'segments' column, you can cast it to an array of integers. Here's a modified version of your view creation statement that might resolve the error:
CREATE VIEW my_view AS SELECT id, CAST(segments AS ARRAY(INTEGER)) AS segments FROM athena_db.my_table
This explicit casting should help Athena correctly interpret the array type when creating the view.
If this approach doesn't work, you might need to consider alternative solutions:
-
Instead of creating a view, you could create a new Iceberg table using a CTAS (CREATE TABLE AS SELECT) statement, which might handle the array type more accurately.
-
You could flatten the array in your view definition if you don't need to preserve the array structure.
-
If possible, update your table schema to use a different representation for the 'segments' column that Athena can handle more easily in views.
It's worth noting that support for complex types in Athena, especially when working with Iceberg tables and views, can sometimes be subject to limitations or ongoing improvements. If the issue persists after trying these workarounds, you may want to contact AWS support for further assistance or to report a potential bug.
Sources
Query Iceberg table data - Amazon Athena
Create Iceberg tables - Amazon Athena
Getting started with Apache Iceberg tables in Amazon Athena SQL - AWS Prescriptive Guidance
Relevant content
- asked 3 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 2 years ago

This is not working either, in fact even a view without specifying the array column is not working such as:
It seems there is an issue while parsing the metadata of the table itself?