This is an automated email from the ASF dual-hosted git repository.
liurenjie1024 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 87483b40 making table provider pub (#650)
87483b40 is described below
commit 87483b40a284b2775d61b7712e4bee92d24a2a96
Author: Alon Agmon <[email protected]>
AuthorDate: Fri Sep 27 04:40:08 2024 +0300
making table provider pub (#650)
Co-authored-by: Alon Agmon <[email protected]>
---
crates/integrations/datafusion/src/lib.rs | 1 +
crates/integrations/datafusion/src/table.rs | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/crates/integrations/datafusion/src/lib.rs
b/crates/integrations/datafusion/src/lib.rs
index c4029011..b64f8fb8 100644
--- a/crates/integrations/datafusion/src/lib.rs
+++ b/crates/integrations/datafusion/src/lib.rs
@@ -24,3 +24,4 @@ pub use error::*;
mod physical_plan;
mod schema;
mod table;
+pub use table::*;
diff --git a/crates/integrations/datafusion/src/table.rs
b/crates/integrations/datafusion/src/table.rs
index 016c6c00..f12d41ee 100644
--- a/crates/integrations/datafusion/src/table.rs
+++ b/crates/integrations/datafusion/src/table.rs
@@ -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`.
@@ -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]