Overview
To query Iceberg tables in Spark, first configure Spark catalogs. Iceberg uses Apache Spark’s DataSourceV2 API for data source implementations.Querying with SQL
In Spark, tables use identifiers that include a catalog name:Metadata Tables
Metadata tables use the Iceberg table name as a namespace:Time Travel
Spark supports time travel queries usingTIMESTAMP AS OF or VERSION AS OF clauses:
Schema Selection in Time Travel
Different time travel queries use different schemas:Branches use the table’s current schema, while tags use the snapshot’s schema at the time the tag was created.
Querying with DataFrames
Load tables as DataFrames usingspark.table:
Loading with Paths
You can load tables using different identifier formats:Time Travel with DataFrames
Use read options for time travel:Incremental Read
Read changes between snapshots:Inspecting Tables
Iceberg provides metadata tables to inspect table state.History
View table history with snapshot lineage:Rows with
is_current_ancestor = false indicate rolled-back commits.Snapshots
View all snapshots in the table:Files
View current data and delete files:0- Data files1- Position delete files2- Equality delete files
Manifests
View manifest files:Partitions
View current partitions with statistics:Entries
View manifest entries with file metadata:Position Delete Files
View position delete records:References
View branches and tags:Metadata Log Entries
View metadata file history:Metadata Tables with DataFrames
Load metadata tables using the DataFrame API:Time Travel with Metadata Tables
Inspect metadata at specific points in time:All Metadata Tables
Metadata tables prefixed withall_ show data across all snapshots:
all_data_files
All data files across all snapshots
all_delete_files
All delete files across all snapshots
all_entries
All manifest entries across all snapshots
all_manifests
All manifest files across all snapshots
Next Steps
Write Data
Learn about INSERT, MERGE, and UPDATE operations
Procedures
Maintain tables with stored procedures
Configuration
Configure read options and performance tuning
Structured Streaming
Stream data with Spark Structured Streaming