This crate contains the official Native Rust implementation of Apache Iceberg.
See the API documentation for examples and the full API.
use std::collections::HashMap;
use std::sync::Arc;
use futures::TryStreamExt;
use iceberg::io::MemoryStorageFactory;
use iceberg::memory::{MemoryCatalogBuilder, MEMORY_CATALOG_WAREHOUSE};
use iceberg::{Catalog, CatalogBuilder, Result, TableIdent};
#[tokio::main]
async fn main() -> Result<()> {
// Connect to a catalog with a memory storage factory.
let catalog = MemoryCatalogBuilder::default()
.with_storage_factory(Arc::new(MemoryStorageFactory))
.load(
"my_catalog",
HashMap::from([(MEMORY_CATALOG_WAREHOUSE.to_string(), "/tmp/warehouse".to_string())]),
)
.await?;
// Load table from catalog.
let table = catalog
.load_table(&TableIdent::from_strs(["hello", "world"])?)
.await?;
// Build table scan.
let stream = table
.scan()
.select(["name", "id"])
.build()?
.to_arrow()
.await?;
// Consume this stream like arrow record batch stream.
let _data: Vec<_> = stream.try_collect().await?;
Ok(())
}For storage backend support (S3, GCS, local filesystem, etc.), use the iceberg-storage-opendal crate. See its README for available backends and feature flags.