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 59abd3a  docs: add `CREATE EXTERNAL TABLE` example in datafusion crate 
(#213)
59abd3a is described below

commit 59abd3aa094ed3ac52b8861bab8e8968879f034c
Author: Jonathan Chen <[email protected]>
AuthorDate: Fri Dec 6 18:05:36 2024 -0500

    docs: add `CREATE EXTERNAL TABLE` example in datafusion crate (#213)
---
 crates/datafusion/src/lib.rs | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/crates/datafusion/src/lib.rs b/crates/datafusion/src/lib.rs
index b5790b8..33f3987 100644
--- a/crates/datafusion/src/lib.rs
+++ b/crates/datafusion/src/lib.rs
@@ -193,9 +193,23 @@ impl TableProvider for HudiDataSource {
 /// // Initialize a new HudiTableFactory
 /// let factory = HudiTableFactory::new();
 ///     
-/// // The factory can now be used to create Hudi tables
+/// // The factory can be used to create Hudi tables
 /// let table = factory.create_table(...)?;
 ///
+///
+/// // Using `CREATE EXTERNAL TABLE` to register Hudi table:
+/// let test_table =  factory.create_table(...)?; // Table with path + url
+/// let ctx = SessionContext::new();
+///
+/// // Register table in session using `CREATE EXTERNAL TABLE` command
+/// let create_table_sql = format!(
+///     "CREATE EXTERNAL TABLE {} STORED AS HUDI LOCATION '{}' {}",
+///     test_table.as_ref(),
+///     test_table.path(),
+///     concat_as_sql_options(options)
+/// );
+/// ctx.sql(create_table_sql.as_str()).await?; // Query against this table
+///
 /// ```
 #[derive(Debug)]
 pub struct HudiTableFactory {}

Reply via email to