This is an automated email from the ASF dual-hosted git repository.

xushiyan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hudi-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new a2738da  docs: add example to `hudi-datafusion` crate (#202)
a2738da is described below

commit a2738da6c15378cae1774a917957a404eb17b242
Author: Jonathan Chen <[email protected]>
AuthorDate: Wed Nov 27 12:42:30 2024 -0500

    docs: add example to `hudi-datafusion` crate (#202)
---
 crates/datafusion/src/lib.rs | 45 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/crates/datafusion/src/lib.rs b/crates/datafusion/src/lib.rs
index 9d2cc38..1bf17ea 100644
--- a/crates/datafusion/src/lib.rs
+++ b/crates/datafusion/src/lib.rs
@@ -44,6 +44,32 @@ use hudi_core::config::utils::empty_options;
 use hudi_core::storage::utils::{get_scheme_authority, parse_uri};
 use hudi_core::table::Table as HudiTable;
 
+/// Create a `HudiDataSource`.
+/// Used for Datafusion to query Hudi tables
+///
+/// # Examples
+///
+/// ```rust
+/// use std::sync::Arc;
+///
+/// use datafusion::error::Result;
+/// use datafusion::prelude::{DataFrame, SessionContext};
+/// use hudi::HudiDataSource;
+///
+/// // Initialize a new DataFusion session context
+/// let ctx = SessionContext::new();
+///
+/// // Create a new HudiDataSource with specific read options
+/// let hudi = HudiDataSource::new_with_options(
+///     "/tmp/trips_table",
+/// [("hoodie.read.as.of.timestamp", "20241122010827898")]).await?;
+///
+/// // Register the Hudi table with the session context
+/// ctx.register_table("trips_table", Arc::new(hudi))?;
+/// let df: DataFrame = ctx.sql("SELECT * from trips_table where city = 
'san_francisco'").await?;
+/// df.show().await?;
+///
+/// ```
 #[derive(Clone, Debug)]
 pub struct HudiDataSource {
     table: Arc<HudiTable>,
@@ -152,6 +178,25 @@ impl TableProvider for HudiDataSource {
     }
 }
 
+/// `HudiTableFactory` is responsible for creating and configuring Hudi tables.
+///
+/// This factory handles the initialization of Hudi tables by creating 
configuration
+/// options from both session state and table creation commands.
+///
+/// # Examples
+///
+/// Creating a new `HudiTableFactory` instance:
+///
+/// ```rust
+/// use hudi::HudiTableFactory;
+///
+/// // Initialize a new HudiTableFactory
+/// let factory = HudiTableFactory::new();
+///     
+/// // The factory can now be used to create Hudi tables
+/// let table = factory.create_table(...)?;
+///
+/// ```
 #[derive(Debug)]
 pub struct HudiTableFactory {}
 

Reply via email to