Skip to main content

SnapshotTable

The SnapshotTable action creates an independent snapshot of an existing table as a new Iceberg table. This creates a separate table that shares the same underlying data files without copying them.

Interface

Overview

The snapshot action creates a new Iceberg table that:
  • References the same data files as the source table
  • Has its own independent metadata and history
  • Can be modified without affecting the source table
  • Requires no data file copying (metadata-only operation)
  • Is useful for creating test environments or table branches
This is particularly useful for:
  • Creating test or development copies of production tables
  • Establishing a baseline for experimentation
  • Creating table snapshots for backup purposes
  • Branching table state for parallel workflows

Methods

as

Sets the table identifier for the newly created Iceberg table.
Parameters:
  • destTableIdent - The destination table identifier (e.g., “db.new_table”)
Returns: this for method chaining Example:

tableLocation

Sets the table location for the newly created Iceberg table.
Parameters:
  • location - The file system path where the new table metadata should be stored
Returns: this for method chaining Example:

tableProperties

Sets multiple table properties in the newly created Iceberg table.
Parameters:
  • properties - A map of property key-value pairs to include
Returns: this for method chaining Example:
Properties with the same key will be overwritten by later calls.

tableProperty

Sets a single table property in the newly created Iceberg table.
Parameters:
  • key - The property key
  • value - The property value
Returns: this for method chaining Example:

executeWith

Sets an executor service for parallel file reading during the snapshot operation.
Parameters:
  • service - The executor service to use
Returns: this for method chaining Example:
By default, the snapshot operation does not use an executor service. This method is optional and may not be supported by all implementations.

Result

The Result interface provides statistics about the snapshot operation.

Methods

importedDataFilesCount

Returns the number of data files that were imported (referenced) into the new table. Returns: long - Number of imported data files

Usage Examples

Basic Table Snapshot

Snapshot with Custom Location

Snapshot with Table Properties

Snapshot with Multiple Properties

Parallel Snapshot for Large Tables

Create Multiple Snapshots

Snapshot for Experimentation

Complete Snapshot Workflow

Best Practices

  1. Use descriptive names: Include timestamps or purpose in snapshot table names
  2. Set appropriate properties: Configure the snapshot table for its intended use case
  3. Document snapshots: Use table properties to record the source and creation time
  4. Clean up snapshots: Remove snapshots when no longer needed to avoid clutter
  5. Consider location: Place test/dev snapshots in appropriate storage locations
  6. Verify after creation: Check that the snapshot has the expected schema and data
The snapshot operation is metadata-only and doesn’t copy data files, making it fast and storage-efficient.

Key Characteristics

  • No data copying: Data files are referenced, not duplicated
  • Independent metadata: Each snapshot has its own metadata and history
  • Fast operation: Metadata-only, completes quickly even for large tables
  • Storage efficient: Only metadata is duplicated, not data
  • Isolated changes: Modifications to the snapshot don’t affect the source
Deleting data files from the source table (e.g., via ExpireSnapshots with file deletion) will affect the snapshot since they share the same files.

Use Cases

Testing and Development

Experimentation

Backup/Baseline