Apache Iceberg for Ruby
Add this line to your application’s Gemfile:
gem "iceberg"Create a client for an Iceberg catalog
catalog = Iceberg::RestCatalog.new(uri: "http://localhost:8181")Create a namespace
catalog.create_namespace("main")Create a table
catalog.create_table("main.events") do |t|
t.bigint "id"
t.float "value"
endOr
df = Polars::DataFrame.new({"id" => [1, 2], "value" => [3.0, 4.0]})
table = catalog.create_table("main.events", schema: df.schema)
table.append(df)Load a table
table = catalog.load_table("main.events")Query a table
table.to_polars.collectIceberg::RestCatalog.new(
uri: "http://localhost:8181"
)Iceberg::SqlCatalog.new(
uri: "postgres://localhost:5432/iceberg",
warehouse: "s3://my-bucket"
)Iceberg::MemoryCatalog.new(
warehouse: "/tmp/warehouse"
)List namespaces
catalog.list_namespacesCreate a namespace
catalog.create_namespace("main")Check if a namespace exists
catalog.namespace_exists?("main")Get the properties of a namespace
catalog.namespace_properties("main")Update a namespace
catalog.update_namespace("main", properties: {})Drop a namespace
catalog.drop_namespace("main")List tables
catalog.list_tables("main")Create a table
catalog.create_table("main.events") do |t|
t.integer "id"
t.float "value"
endLoad a table
catalog.load_table("main.events")Check if a table exists
catalog.table_exists?("main.events")Rename a table
catalog.rename_table("main.events", "main.events2")Register a table
catalog.register_table("main.events", "metadata.json")Drop a table
catalog.drop_table("main.events")Load a static table
Iceberg::StaticTable.new("metadata.json")View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/iceberg-ruby.git
cd iceberg-ruby
bundle install
bundle exec rake compile
# memory catalog
bundle exec rake test:memory
# REST catalog
docker run -p 8181:8181 apache/iceberg-rest-fixture
bundle exec rake test:rest
# SQL catalog
createdb iceberg_ruby_test
bundle exec rake test:sql