Skip to content

Commit

Permalink
making table provider pub (apache#650)
Browse files Browse the repository at this point in the history
Co-authored-by: Alon Agmon <alon.agmon@appsflyer.com>
  • Loading branch information
a-agmon and Alon Agmon authored Sep 27, 2024
1 parent 984c91e commit 87483b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/integrations/datafusion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ pub use error::*;
mod physical_plan;
mod schema;
mod table;
pub use table::*;
9 changes: 8 additions & 1 deletion crates/integrations/datafusion/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::physical_plan::scan::IcebergTableScan;

/// Represents a [`TableProvider`] for the Iceberg [`Catalog`],
/// managing access to a [`Table`].
pub(crate) struct IcebergTableProvider {
pub struct IcebergTableProvider {
/// A table in the catalog.
table: Table,
/// A reference-counted arrow `Schema`.
Expand All @@ -56,6 +56,13 @@ impl IcebergTableProvider {

Ok(IcebergTableProvider { table, schema })
}

/// Asynchronously tries to construct a new [`IcebergTableProvider`]
/// using the given table. Can be used to create a table provider from an existing table regardless of the catalog implementation.
pub async fn try_new_from_table(table: Table) -> Result<Self> {
let schema = Arc::new(schema_to_arrow_schema(table.metadata().current_schema())?);
Ok(IcebergTableProvider { table, schema })
}
}

#[async_trait]
Expand Down

0 comments on commit 87483b4

Please sign in to comment.