Skip to content
المشاريع

apache/datafusion-iceberg

عرض على GitHub

حول

Apache DataFusion Iceberg Integration

البيانات والتحليلات

كيف تُقاس هذه الأرقام

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
+٣
خلال 15 يومًا
+٣
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

Apache Iceberg Table Provider for Apache DataFusion

This repository connects Apache Iceberg tables to Apache DataFusion. The iceberg-datafusion crate provides table providers for querying Iceberg data and for inserting rows through an Iceberg catalog.

Workspace

Query an existing table

Register IcebergTableProviderFactory in a DataFusion session, then point an external table at an existing Iceberg metadata file:

use std::sync::Arc;

use datafusion::execution::session_state::SessionStateBuilder;
use datafusion::prelude::SessionContext;
use iceberg_datafusion::IcebergTableProviderFactory;

async fn query_table() -> datafusion::error::Result<()> {
    let mut state = SessionStateBuilder::new().with_default_features().build();
    state.table_factories_mut().insert(
        "ICEBERG".to_string(),
        Arc::new(IcebergTableProviderFactory::new()),
    );
    let ctx = SessionContext::new_with_state(state);

    ctx.sql(
        "CREATE EXTERNAL TABLE trips STORED AS ICEBERG \
         LOCATION '/absolute/path/to/table/metadata/v1.metadata.json'",
    )
    .await?
    .collect()
    .await?;

    let batches = ctx
        .sql("SELECT * FROM trips LIMIT 10")
        .await?
        .collect()
        .await?;
    println!("{batches:?}");
    Ok(())
}

Replace the metadata path with one from an existing table whose data files are accessible to the process. External-table registration reads an existing table; it does not create one. For catalog-backed access and inserts, register an IcebergCatalogProvider with a configured Iceberg Catalog. See the catalog provider and insert tests for examples.

Register an Iceberg catalog

Pass a REST client, an in-memory catalog, or a caching wrapper to IcebergCatalogProvider::catalog_builder(client).build().await?. To expose a fixed set of writable tables, supply their identifiers before building.

let reporting = IcebergCatalogProvider::catalog_builder(client)
    .with_fixed_tables([TableIdent::from_strs(["sales", "orders"])?])
    .build().await?;
let archive = IcebergCatalogProvider::static_builder()
    .add_static_table(orders)
    .add_snapshot(shipments, snapshot_id)
    .build()?;

The workspace uses a pinned iceberg-rust Git revision. Applications that also depend on Iceberg crates should use the same revision shown in Cargo.toml so Cargo uses one Iceberg crate source.

Development

The repository's rust-toolchain.toml selects the Rust toolchain used by CI. From the repository root, run:

cargo fmt --all -- --check
cargo clippy --workspace --locked --all-targets -- -D warnings
cargo test --workspace --locked

This project is licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…