# `Iceberg.Catalog`
[🔗](https://github.com/Ziinc/iceberg-ex/blob/v0.1.0/lib/iceberg/catalog.ex#L1)

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`).

# `namespace`

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

# `result`

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

# `t`

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

# `create_namespace`

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

# `create_table`

```elixir
@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`

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

# `drop_table`

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

Drops a table from the catalog, leaving its files.

# `get_namespace`

```elixir
@spec get_namespace(t(), namespace(), keyword()) ::
  result(%{required(String.t()) =&gt; String.t()})
```

The namespace's properties.

# `list_namespaces`

```elixir
@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`

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

The names of the tables in a namespace.

# `load_table`

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

# `namespace_exists`

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

# `new`

```elixir
@spec new(atom(), %{required(String.t()) =&gt; 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`

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

# `table_exists`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
