Skip to content

Commit 87483b4

Browse files
a-agmonAlon Agmon
and
Alon Agmon
authored
making table provider pub (apache#650)
Co-authored-by: Alon Agmon <[email protected]>
1 parent 984c91e commit 87483b4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

crates/integrations/datafusion/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ pub use error::*;
2424
mod physical_plan;
2525
mod schema;
2626
mod table;
27+
pub use table::*;

crates/integrations/datafusion/src/table.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::physical_plan::scan::IcebergTableScan;
3333

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

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

6168
#[async_trait]

0 commit comments

Comments
 (0)