ExIceberg.Types (ExIceberg v0.3.0)

Type definitions for Iceberg schemas.

This module provides structured type definitions that correspond to the Rust NIF types, offering a more type-safe and idiomatic approach compared to string-based type definitions.

Summary

Functions

Creates a decimal type with the specified precision and scale.

Creates a new field with the given name, type, and options.

Creates a fixed-length binary type with the specified length.

Creates a list type with the specified element type.

Creates a map type with the specified key and value types.

Creates a struct type with the specified fields.

Types

@type type() ::
  :boolean
  | :int
  | :long
  | :float
  | :double
  | :string
  | :uuid
  | :date
  | :time
  | :timestamp
  | :timestamptz
  | :timestamp_ns
  | :timestamptz_ns
  | :binary
  | {:decimal, precision: pos_integer(), scale: non_neg_integer()}
  | {:fixed, [{:length, pos_integer()}]}
  | {:list, element_type: type(), element_required: boolean()}
  | {:map, key_type: type(), value_type: type(), value_required: boolean()}
  | {:struct, [{:fields, [ExIceberg.Types.Field.t()]}]}

Functions

Link to this function

decimal(precision, scale)

Creates a decimal type with the specified precision and scale.

Examples

iex> ExIceberg.Types.decimal(10, 2)
{:decimal, precision: 10, scale: 2}
Link to this function

field(name, type, opts \\ [])

Creates a new field with the given name, type, and options.

Examples

iex> ExIceberg.Types.field("id", :long, required: true)
%ExIceberg.Types.Field{name: "id", field_type: :long, required: true, field_id: nil}

iex> ExIceberg.Types.field("price", {:decimal, precision: 10, scale: 2})
%ExIceberg.Types.Field{name: "price", field_type: {:decimal, precision: 10, scale: 2}, required: false, field_id: nil}

Creates a fixed-length binary type with the specified length.

Examples

iex> ExIceberg.Types.fixed(16)
{:fixed, length: 16}
Link to this function

list(element_type, opts \\ [])

Creates a list type with the specified element type.

Examples

iex> ExIceberg.Types.list(:string)
{:list, element_type: :string, element_required: false}

iex> ExIceberg.Types.list(:int, element_required: true)
{:list, element_type: :int, element_required: true}
Link to this function

map(key_type, value_type, opts \\ [])

Creates a map type with the specified key and value types.

Examples

iex> ExIceberg.Types.map(:string, :int)
{:map, key_type: :string, value_type: :int, value_required: false}

iex> ExIceberg.Types.map(:string, :string, value_required: true)
{:map, key_type: :string, value_type: :string, value_required: true}

Creates a struct type with the specified fields.

Examples

iex> ExIceberg.Types.struct([
...>   ExIceberg.Types.field("street", :string),
...>   ExIceberg.Types.field("city", :string),
...>   ExIceberg.Types.field("zip", :int)
...> ])
{:struct, fields: [
  %ExIceberg.Types.Field{name: "street", field_type: :string, required: false, field_id: nil},
  %ExIceberg.Types.Field{name: "city", field_type: :string, required: false, field_id: nil},
  %ExIceberg.Types.Field{name: "zip", field_type: :int, required: false, field_id: nil}
]}