Table Scans
The most common way to read an Iceberg table is using aTableScan. A table scan reads the current snapshot of the table and supports various refinements.
Basic Table Scan
Projection (Column Selection)
Limit the columns read to improve performance:Filtering Data
Apply row-level filters to reduce the data scanned:Filters are pushed down to skip entire files and row groups when possible, dramatically improving query performance.
Case Sensitivity
Control whether column name matching is case-sensitive:Time Travel Queries
Iceberg maintains table history through snapshots, enabling queries as of a specific point in time.Read a Specific Snapshot
Read as of Timestamp
Read Using Named References
Batch Scans
Batch scans are optimized for reading large amounts of data in batch processing jobs:Incremental Scans
Read only the data that changed between two snapshots.Incremental Append Scan
Read new rows appended between snapshots:Incremental Changelog Scan
Read all changes (inserts, updates, deletes) between snapshots:Incremental scans are ideal for building streaming pipelines and incremental ETL processes.
Advanced Scan Options
Planning with Custom Executor
Use a custom thread pool for scan planning:Include Column Statistics
Load column statistics with each data file:Ignore Residual Filters
Skip row-level filtering (filter files only):Table Properties Override
Override table properties for a specific scan:Planning Tasks
1
Plan individual files
Plan tasks where each task reads a single file:
2
Plan balanced task groups
Plan tasks that combine small files and split large files:
Balanced task groups improve parallelism by creating evenly-sized tasks based on
read.split.target-size.Metrics Reporting
Attach custom metrics reporters to track scan performance:Complete Example
Best Practices
- Use projection: Only read the columns you need to reduce I/O
- Apply filters early: Push down predicates to skip entire files
- Leverage time travel: Access historical data without maintaining separate copies
- Monitor metrics: Track scan performance to identify optimization opportunities
- Use incremental scans: For streaming and CDC use cases, process only changed data
- Plan balanced tasks: Use
planTasks()for better parallelism in distributed engines