Skip to main content

Table Interface

The Table 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

The Table 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()

Returns the full name for this table. Returns: The table’s name

schema()

Returns the current Schema for this table. Returns: This table’s schema See also: Schema API

schemas()

Returns a map of all schemas for this table, keyed by schema ID. Returns: Map of schema ID to Schema

spec()

Returns the current PartitionSpec for this table. Returns: This table’s partition spec See also: PartitionSpec API

specs()

Returns a map of all partition specs for this table, keyed by spec ID. Returns: Map of spec ID to PartitionSpec

sortOrder()

Returns the current SortOrder for this table. Returns: This table’s sort order See also: SortOrder API

sortOrders()

Returns a map of all sort orders for this table, keyed by order ID. Returns: Map of order ID to SortOrder

properties()

Returns table properties as a string map. Returns: This table’s properties map

location()

Returns the table’s base location. Returns: This table’s location (e.g., s3://bucket/warehouse/db/table)

uuid()

Returns the UUID of the table. Returns: The table’s UUID

refresh()

Refreshes the current table metadata from storage. This method should be called to pick up changes made by other writers.

Snapshot Access

currentSnapshot()

Returns the current 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)

Returns the snapshot with the given ID, or null if not found.
long
required
The snapshot ID to retrieve
Returns: The snapshot with the given ID, or null

snapshot(String name)

Returns the snapshot referenced by the given name or null if no such reference exists.
String
required
The snapshot reference name (e.g., “main”, “audit”)
Returns: The referenced snapshot, or null

snapshots()

Returns all snapshots for this table. Returns: An iterable of snapshots

refs()

Returns the current snapshot references for the table. Returns: Map of reference name to SnapshotRef

history()

Returns the snapshot history of this table. Returns: A list of history entries

Scan Operations

newScan()

Creates a new TableScan for this table. Once created, the scan can be refined to project columns and filter data. Returns: A new table scan Example:

newBatchScan()

Creates a new BatchScan for this table. Returns: A new batch scan

newIncrementalAppendScan()

Creates a new incremental append scan for this table. Returns: An incremental scan for append-only snapshots Throws: UnsupportedOperationException if not supported

newIncrementalChangelogScan()

Creates a new incremental changelog scan for this table. Returns: An incremental changelog scan Throws: UnsupportedOperationException if not supported

newPartitionStatisticsScan()

Creates a new partition statistics scan for this table. Returns: A partition statistics scan Throws: UnsupportedOperationException if not supported

Write Operations

newAppend()

Creates a new AppendFiles API to add files to this table and commit. Returns: A new AppendFiles instance Example:

newFastAppend()

Creates a new AppendFiles API optimized for fast commits.
Fast appends skip extra work to commit quickly but may cause split planning to slow down over time. Not recommended for normal writes.
Returns: A new AppendFiles instance

newRewrite()

Creates a new RewriteFiles API to replace files in this table and commit. Returns: A new RewriteFiles instance

rewriteManifests()

Creates a new RewriteManifests API to replace manifests for this table and commit. Returns: A new RewriteManifests instance

newOverwrite()

Creates a new OverwriteFiles API to overwrite files by a filter expression. Returns: A new OverwriteFiles instance Example:

newRowDelta()

Creates a new RowDelta API to remove or replace rows in existing data files. Returns: A new RowDelta instance

newReplacePartitions()

Not recommended. This is provided for Hive SQL compatibility. Use newOverwrite() instead.
Creates a new ReplacePartitions API to dynamically overwrite partitions. Returns: A new ReplacePartitions instance

newDelete()

Creates a new DeleteFiles API to delete files in this table and commit. Returns: A new DeleteFiles instance

Schema and Metadata Evolution

updateSchema()

Creates a new UpdateSchema API to alter the columns of this table and commit the change. Returns: A new UpdateSchema instance Example:

updateSpec()

Creates a new UpdatePartitionSpec API to alter the partition spec and commit the change. Returns: A new UpdatePartitionSpec instance

updateProperties()

Creates a new UpdateProperties API to update table properties and commit the changes. Returns: A new UpdateProperties instance Example:

replaceSortOrder()

Creates a new ReplaceSortOrder API to set the table sort order and commit the change. Returns: A new ReplaceSortOrder instance

updateLocation()

Creates a new UpdateLocation API to update table location and commit the changes. Returns: A new UpdateLocation instance

Snapshot Management

expireSnapshots()

Creates a new ExpireSnapshots API to expire snapshots in this table and commit. Returns: A new ExpireSnapshots instance Example:

manageSnapshots()

Creates a new ManageSnapshots API to manage snapshots in this table and commit. Returns: A new ManageSnapshots instance

Statistics

statisticsFiles()

Returns the current statistics files for the table. Returns: List of statistics files

partitionStatisticsFiles()

Returns the current partition statistics files for the table. Returns: List of partition statistics files

updateStatistics()

Creates a new UpdateStatistics API to add or remove statistics files. Returns: A new UpdateStatistics instance Throws: UnsupportedOperationException if not supported

updatePartitionStatistics()

Creates a new UpdatePartitionStatistics API to add or remove partition statistics files. Returns: A new UpdatePartitionStatistics instance Throws: UnsupportedOperationException if not supported

Transactions

newTransaction()

Creates a new Transaction API to commit multiple table operations at once. Returns: A new Transaction instance Example:

File I/O and Encryption

io()

Returns a FileIO instance to read and write table data and metadata files. Returns: The FileIO for this table

encryption()

Returns an EncryptionManager to encrypt and decrypt data files. Returns: The EncryptionManager for this table

locationProvider()

Returns a 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