Iceberg.Catalog (iceberg v0.1.0)

Copy Markdown View Source

An Iceberg catalog: an Iceberg REST catalog, Amazon S3 Tables, or an in-memory catalog (for tests and local work).

{:ok, catalog} =
  Iceberg.Catalog.new(:rest, %{
    "uri" => "https://catalog.example.com",
    "warehouse" => "analytics",
    "token" => token,
    "s3.region" => "eu-west-1"
  })

Properties are iceberg-rust's, as string keys and values: the catalog's own (uri, warehouse, token, credential, table_bucket_arn, ...) and the storage's (s3.endpoint, s3.access-key-id, s3.path-style-access, ...). The memory catalog takes warehouse, such as "file:///tmp/warehouse".

A namespace is a string (one level) or a list of levels. Every function takes timeout: (milliseconds, default :infinity).

Summary

Types

namespace()

@type namespace() :: String.t() | [String.t()]

result(ok)

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

t()

@type t() :: %Iceberg.Catalog{kind: atom(), resource: reference()}

Functions

create_namespace(c, namespace, props \\ %{}, opts \\ [])

@spec create_namespace(t(), namespace(), map(), keyword()) ::
  :ok | {:error, Iceberg.Error.t()}

create_table(c, namespace, name, schema, opts \\ [])

@spec create_table(t(), namespace(), String.t(), map(), keyword()) ::
  result(Iceberg.Table.t())

Creates a table. schema is in the spec's JSON shape, as built by Iceberg.Schema.new/1.

Options:

  • :partition_by - partition fields, each a source column name (identity) or {column, transform} / {column, transform, name}, where transform is :identity, :year, :month, :day, :hour, :void, {:bucket, n} or {:truncate, width}
  • :properties - table properties
  • :location - the table's location (default: chosen by the catalog)
  • :format_version - 1, 2 (default) or 3
  • :timeout

drop_namespace(c, namespace, opts \\ [])

@spec drop_namespace(t(), namespace(), keyword()) :: :ok | {:error, Iceberg.Error.t()}

drop_table(c, namespace, name, opts \\ [])

@spec drop_table(t(), namespace(), String.t(), keyword()) ::
  :ok | {:error, Iceberg.Error.t()}

Drops a table from the catalog, leaving its files.

get_namespace(c, namespace, opts \\ [])

@spec get_namespace(t(), namespace(), keyword()) ::
  result(%{required(String.t()) => String.t()})

The namespace's properties.

list_namespaces(c, parent \\ nil, opts \\ [])

@spec list_namespaces(t(), namespace() | nil, keyword()) :: result([[String.t()]])

The namespaces under parent (top-level ones by default), as lists of levels.

list_tables(c, namespace, opts \\ [])

@spec list_tables(t(), namespace(), keyword()) :: result([String.t()])

The names of the tables in a namespace.

load_table(c, namespace, name, opts \\ [])

@spec load_table(t(), namespace(), String.t(), keyword()) :: result(Iceberg.Table.t())

namespace_exists(c, namespace, opts \\ [])

@spec namespace_exists(t(), namespace(), keyword()) :: result(boolean())

new(kind, props, opts \\ [])

@spec new(atom(), %{required(String.t()) => String.t()}, keyword()) :: result(t())

Connects to a catalog of kind (:rest, :s3tables or :memory).

Options: :name (the catalog's name, default "iceberg") and :timeout.

rename_table(c, arg1, arg2, opts \\ [])

@spec rename_table(
  t(),
  {namespace(), String.t()},
  {namespace(), String.t()},
  keyword()
) ::
  :ok | {:error, Iceberg.Error.t()}

table_exists(c, namespace, name, opts \\ [])

@spec table_exists(t(), namespace(), String.t(), keyword()) :: result(boolean())