ExIceberg.Rest.Catalog (ExIceberg v0.3.0)
REST catalog implementation using Rust NIFs.
Summary
Functions
Creates a new namespace in the catalog.
Creates a table in the catalog using structured field definitions.
Drops a table from the catalog.
Lists all namespaces in the catalog.
Creates a new REST catalog instance.
Checks if a table exists in the catalog.
Types
Functions
create_namespace(catalog, namespace, properties \\ %{})
Creates a new namespace in the catalog.
Parameters
catalog- The catalog structnamespace- The namespace name as a stringproperties- Map of properties for the namespace
Returns
{:ok, updated_catalog, response} - Success with response map
{:error, updated_catalog, reason} - Error with reason
Examples
{:ok, catalog, response} = ExIceberg.Rest.Catalog.create_namespace(catalog, "my_namespace", %{})
# response might be %{"namespace" => ["my_namespace"]}
create_table(catalog, namespace, table_name, fields, properties \\ %{})
Creates a table in the catalog using structured field definitions.
Parameters
catalog- The catalog structnamespace- The namespace name as a stringtable_name- The table name as a stringfields- List ofExIceberg.Types.Fieldstructsproperties- Map of table properties (optional)
Returns
{:ok, updated_catalog, response} - Success with response map
{:error, updated_catalog, reason} - Error with reason
Note
This function now uses the structured type system. For defining tables,
it's recommended to use ExIceberg.Schema for a more declarative approach:
defmodule MySchema do
use ExIceberg.Schema
schema "my_table" do
field :id, :long, required: true
field :name, :string
field :balance, ExIceberg.Types.decimal(10, 2)
end
end
MySchema.create_table(catalog, namespace)Examples
# Using structured field definitions directly
fields = [
ExIceberg.Types.field("id", :long, required: true),
ExIceberg.Types.field("name", :string),
ExIceberg.Types.field("balance", ExIceberg.Types.decimal(10, 2)),
ExIceberg.Types.field("tags", ExIceberg.Types.list(:string)),
ExIceberg.Types.field("address", ExIceberg.Types.struct([
ExIceberg.Types.field("street", :string),
ExIceberg.Types.field("city", :string)
]))
]
{:ok, catalog, response} = ExIceberg.Rest.Catalog.create_table(catalog, "my_namespace", "my_table", fields, %{"owner" => "test"})
drop_table(catalog, namespace, table_name)
Drops a table from the catalog.
Parameters
catalog- The catalog structnamespace- The namespace name as a stringtable_name- The table name as a string
Returns
{:ok, updated_catalog, response} - Success with response map
{:error, updated_catalog, reason} - Error with reason
Examples
{:ok, catalog, response} = ExIceberg.Rest.Catalog.drop_table(catalog, "my_namespace", "my_table")
# response might be %{"table" => "my_namespace.my_table"}
list_namespaces(catalog)
Lists all namespaces in the catalog.
Parameters
catalog- The catalog struct
Returns
{:ok, updated_catalog, namespaces} - Success with list of namespace names
{:error, updated_catalog, reason} - Error with reason
Examples
{:ok, catalog, namespaces} = ExIceberg.Rest.Catalog.list_namespaces(catalog)
# namespaces might be ["default", "analytics", "staging"]
new(name, config)
Creates a new REST catalog instance.
Parameters
name- The name of the catalogconfig- Configuration map containing REST catalog settings
Returns
%ExIceberg.Rest.Catalog{} - The catalog struct
Examples
config = %{
uri: "http://localhost:8181",
token: "my-token",
warehouse: "s3://my-bucket/warehouse"
}
# Or with OAuth2:
config = %{
uri: "http://localhost:8181",
credential: "client_id:client_secret",
oauth2_server_uri: "http://keycloak:8080/realms/iceberg/protocol/openid-connect/token",
scope: "lakekeeper",
warehouse: "s3://my-bucket/warehouse"
}
catalog = ExIceberg.Rest.Catalog.new("my_catalog", config)
table_exists?(catalog, namespace, table_name)
Checks if a table exists in the catalog.
Parameters
catalog- The catalog structnamespace- The namespace name as a stringtable_name- The table name as a string
Returns
{:ok, updated_catalog, exists} - Success with boolean indicating if table exists
{:error, updated_catalog, reason} - Error with reason
Examples
{:ok, catalog, exists} = ExIceberg.Rest.Catalog.table_exists?(catalog, "my_namespace", "my_table")
# exists is true or false