Query Iceberg table data
To query an Iceberg dataset, use a standard SELECT
statement like the
following. Queries follow the Apache Iceberg format v2 spec
SELECT * FROM [
db_name
.]table_name
[WHEREpredicate
]
To optimize query times, all predicates are pushed down to where the data lives.
For information about time travel and version travel queries, see Perform time travel and version travel queries.
Create and query views with Iceberg tables
To create and query Athena views on Iceberg tables, use CREATE VIEW
views as described in Work with views.
Example:
CREATE VIEW view1 AS SELECT * FROM
iceberg_table
SELECT * FROM view1
If you are interested in using the Iceberg
view specification
Query Iceberg table metadata
In a SELECT
query, you can use the following properties after
table_name
to query Iceberg table metadata:
-
$files – Shows a table's current data files.
-
$manifests – Shows a table's current file manifests.
-
$history – Shows a table's history.
-
$partitions – Shows a table's current partitions.
-
$snapshots – Shows a table's snapshots.
-
$refs – Shows a table's references.
Examples
The following statement lists the files for an Iceberg table.
SELECT * FROM "
dbname
"."tablename
$files"
The following statement lists the manifests for an Iceberg table.
SELECT * FROM "
dbname
"."tablename
$manifests"
The following statement shows the history for an Iceberg table.
SELECT * FROM "
dbname
"."tablename
$history"
The following example shows the partitions for an Iceberg table.
SELECT * FROM "
dbname
"."tablename
$partitions"
The following example lists the snapshots for an Iceberg table.
SELECT * FROM "
dbname
"."tablename
$snapshots"
The following example shows the references for an Iceberg table.
SELECT * FROM "
dbname
"."tablename
$refs"
Use Lake Formation fine-grained access control
Athena engine version 3 supports Lake Formation fine-grained access control with Iceberg tables, including column level and row level security access control. This access control works with time travel queries and with tables that have performed schema evolution. For more information, see Lake Formation fine-grained access control and Athena workgroups.
If you created your Iceberg table outside of Athena, use Apache Iceberg SDK