The TableScan interface provides a flexible API for configuring and executing scans over Iceberg tables.
Overview
TableScan extends the base Scan interface and provides methods to configure which snapshot to read, apply filters, and project columns. Scans are immutable - each configuration method returns a new scan instance.
Interface
Core Methods
table()
Returns the table from which this scan loads data.
Returns: This scan’s table
Example:
useSnapshot()
Creates a new scan that will use the given snapshot by ID.
Parameters:
snapshotId - A snapshot ID
Returns: A new scan based on this with the given snapshot ID
Throws: IllegalArgumentException if the snapshot cannot be found
Example:
useRef()
Creates a new scan that will use the given reference (branch or tag).
Parameters:
Returns: A new scan based on the given reference
Throws: IllegalArgumentException if a reference with the given name could not be found
Example:
asOfTime()
Creates a new scan that will use the most recent snapshot as of the given time.
Parameters:
timestampMillis - A timestamp in milliseconds since the epoch
Returns: A new scan based on this with the current snapshot at the given time
Throws: IllegalArgumentException if the snapshot cannot be found or time travel is attempted on a tag
Example:
snapshot()
Returns the snapshot that will be used by this scan.
Returns: The Snapshot this scan will use
Example:
Deprecated Methods
appendsBetween() (Deprecated)
Deprecated since 1.0.0, will be removed in 2.0.0. Use Table.newIncrementalAppendScan() instead.
Creates a scan to read appended data from one snapshot to another.
Parameters:
fromSnapshotId - The last snapshot id read by the user (exclusive)
toSnapshotId - Read append data up to this snapshot id (inclusive)
Returns: A table scan which can read append data in the range
appendsAfter() (Deprecated)
Deprecated since 1.0.0, will be removed in 2.0.0. Use Table.newIncrementalAppendScan() instead.
Creates a scan to read appended data from a snapshot to the current snapshot.
Parameters:
fromSnapshotId - The last snapshot id read by the user (exclusive)
Returns: A table scan which can read append data from the snapshot to current
Examples
Basic Table Scan
Time Travel Query
Scanning a Specific Snapshot
Scanning a Named Reference
Filtered Scan with Projection
Checking Scan Configuration
Scan Planning
TableScan extends the Scan interface which provides methods for planning:
planFiles() - Returns an iterable of FileScanTask objects
planTasks() - Returns an iterable of CombinedScanTask objects (groups of files)
See Also