Table Interface
TheTable interface is the primary entry point for interacting with Apache Iceberg tables. It provides access to table metadata, scan operations, and write APIs.
Package: org.apache.iceberg
Overview
TheTable interface represents an Iceberg table and provides methods for:
- Accessing table metadata (schema, partition spec, sort order)
- Creating scans to read data
- Performing write operations (append, rewrite, overwrite, delete)
- Managing snapshots and history
- Evolving table structure
Metadata Access
name()
schema()
Schema for this table.
Returns: This table’s schema
See also: Schema API
schemas()
spec()
PartitionSpec for this table.
Returns: This table’s partition spec
See also: PartitionSpec API
specs()
sortOrder()
SortOrder for this table.
Returns: This table’s sort order
See also: SortOrder API
sortOrders()
properties()
location()
s3://bucket/warehouse/db/table)
uuid()
refresh()
Snapshot Access
currentSnapshot()
Snapshot for this table, or null if there are no snapshots.
Returns: The current table snapshot, or null
See also: Snapshot API
snapshot(long snapshotId)
long
required
The snapshot ID to retrieve
snapshot(String name)
String
required
The snapshot reference name (e.g., “main”, “audit”)
snapshots()
refs()
history()
Scan Operations
newScan()
TableScan for this table.
Once created, the scan can be refined to project columns and filter data.
Returns: A new table scan
Example:
newBatchScan()
BatchScan for this table.
Returns: A new batch scan
newIncrementalAppendScan()
UnsupportedOperationException if not supported
newIncrementalChangelogScan()
UnsupportedOperationException if not supported
newPartitionStatisticsScan()
UnsupportedOperationException if not supported
Write Operations
newAppend()
AppendFiles API to add files to this table and commit.
Returns: A new AppendFiles instance
Example:
newFastAppend()
AppendFiles API optimized for fast commits.
Returns: A new AppendFiles instance
newRewrite()
RewriteFiles API to replace files in this table and commit.
Returns: A new RewriteFiles instance
rewriteManifests()
RewriteManifests API to replace manifests for this table and commit.
Returns: A new RewriteManifests instance
newOverwrite()
OverwriteFiles API to overwrite files by a filter expression.
Returns: A new OverwriteFiles instance
Example:
newRowDelta()
RowDelta API to remove or replace rows in existing data files.
Returns: A new RowDelta instance
newReplacePartitions()
ReplacePartitions API to dynamically overwrite partitions.
Returns: A new ReplacePartitions instance
newDelete()
DeleteFiles API to delete files in this table and commit.
Returns: A new DeleteFiles instance
Schema and Metadata Evolution
updateSchema()
UpdateSchema API to alter the columns of this table and commit the change.
Returns: A new UpdateSchema instance
Example:
updateSpec()
UpdatePartitionSpec API to alter the partition spec and commit the change.
Returns: A new UpdatePartitionSpec instance
updateProperties()
UpdateProperties API to update table properties and commit the changes.
Returns: A new UpdateProperties instance
Example:
replaceSortOrder()
ReplaceSortOrder API to set the table sort order and commit the change.
Returns: A new ReplaceSortOrder instance
updateLocation()
UpdateLocation API to update table location and commit the changes.
Returns: A new UpdateLocation instance
Snapshot Management
expireSnapshots()
ExpireSnapshots API to expire snapshots in this table and commit.
Returns: A new ExpireSnapshots instance
Example:
manageSnapshots()
ManageSnapshots API to manage snapshots in this table and commit.
Returns: A new ManageSnapshots instance
Statistics
statisticsFiles()
partitionStatisticsFiles()
updateStatistics()
UpdateStatistics API to add or remove statistics files.
Returns: A new UpdateStatistics instance
Throws: UnsupportedOperationException if not supported
updatePartitionStatistics()
UpdatePartitionStatistics API to add or remove partition statistics files.
Returns: A new UpdatePartitionStatistics instance
Throws: UnsupportedOperationException if not supported
Transactions
newTransaction()
Transaction API to commit multiple table operations at once.
Returns: A new Transaction instance
Example:
File I/O and Encryption
io()
FileIO instance to read and write table data and metadata files.
Returns: The FileIO for this table
encryption()
EncryptionManager to encrypt and decrypt data files.
Returns: The EncryptionManager for this table
locationProvider()
LocationProvider to provide locations for new data files.
Returns: The LocationProvider for this table
Usage Examples
Reading Table Metadata
Scanning with Filters
Appending Data
Schema Evolution
Time Travel
Source Code Reference
Source:org/apache/iceberg/Table.java:30