Iceberg.Table (iceberg v0.1.0)

Copy Markdown View Source

A loaded Iceberg table: its metadata, scans and appends.

Table data crosses into and out of Elixir as an Arrow IPC stream binary. With the optional :explorer dependency, appends also take an Explorer.DataFrame and to_dataframe/2 loads a scan.

A table value is a snapshot of the table's metadata at load or commit time; refresh/2 reloads it. Every function but metadata/1 takes timeout: (milliseconds, default :infinity).

Summary

Functions

Writes and commits data in one go: write_data_files/3, then fast_append/3, taking both functions' options.

Commits data files to the table as a new append snapshot. If the table has moved on since table was loaded, the commit is retried on the latest metadata, as iceberg-rust's commit.retry.* table properties allow; when many writers commit to one table at once, the retries can run out, and the error is :catalog_commit_conflicts with retryable: true. With no rows and no snapshot properties to add, the table is returned as it is.

The table's metadata in the Iceberg spec's JSON shape (string keys: "format-version", "current-schema-id", "schemas", "partition-specs", "current-snapshot-id", "snapshots" with their "summary", "properties", ...).

Reloads the table from its catalog.

Reads the table as an Arrow IPC stream.

Writes data as Parquet data files in the table's location, without committing them. Columns are matched to the table's by name and cast to their types; a missing optional column is written as nulls. Partitioned tables get a file per partition.

Types

data()

@type data() :: binary() | struct()

result(ok)

@type result(ok) :: {:ok, ok} | {:error, Iceberg.Error.t()}

t()

@type t() :: %Iceberg.Table{
  name: String.t(),
  namespace: [String.t()],
  resource: reference()
}

Functions

append(table, data, opts \\ [])

@spec append(t(), data(), keyword()) :: result(t())

Writes and commits data in one go: write_data_files/3, then fast_append/3, taking both functions' options.

fast_append(table, data_files, opts \\ [])

@spec fast_append(t(), Iceberg.DataFiles.t() | [Iceberg.DataFiles.t()], keyword()) ::
  result(t())

Commits data files to the table as a new append snapshot. If the table has moved on since table was loaded, the commit is retried on the latest metadata, as iceberg-rust's commit.retry.* table properties allow; when many writers commit to one table at once, the retries can run out, and the error is :catalog_commit_conflicts with retryable: true. With no rows and no snapshot properties to add, the table is returned as it is.

Options:

  • :snapshot_properties - extra entries for the snapshot's summary (not "operation", which the commit sets)
  • :check_duplicate - refuse files already in the table (default true)
  • :timeout

metadata(table)

@spec metadata(t()) :: map()

The table's metadata in the Iceberg spec's JSON shape (string keys: "format-version", "current-schema-id", "schemas", "partition-specs", "current-snapshot-id", "snapshots" with their "summary", "properties", ...).

refresh(table, opts \\ [])

@spec refresh(t(), keyword()) :: result(t())

Reloads the table from its catalog.

scan(table, opts \\ [])

@spec scan(t(), keyword()) :: result(binary())

Reads the table as an Arrow IPC stream.

Options:

  • :select - column names (default: all)
  • :filter - a row filter, see Iceberg.Filter
  • :snapshot_id - read this snapshot instead of the current one
  • :batch_size - rows per Arrow record batch
  • :case_sensitive - match column names case-sensitively (default true)
  • :timeout

to_dataframe(table, opts \\ [])

@spec to_dataframe(t(), keyword()) :: result(Explorer.DataFrame.t())

Scans the table (see scan/2) into an Explorer.DataFrame.

write_data_files(table, data, opts \\ [])

@spec write_data_files(t(), data(), keyword()) :: result(Iceberg.DataFiles.t())

Writes data as Parquet data files in the table's location, without committing them. Columns are matched to the table's by name and cast to their types; a missing optional column is written as nulls. Partitioned tables get a file per partition.

Options:

  • :file_prefix - the data files' name prefix (default: a random UUID). Files are named <prefix>-<n>.parquet, so a retry with the same prefix overwrites the files of an attempt that never committed.
  • :properties - write.* table properties to override for this write, such as "write.parquet.compression-codec" or "write.target-file-size-bytes"
  • :timeout