This is an automated email from the ASF dual-hosted git repository. danny0405 pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/asf-site by this push: new f138422fcb9 [HUDI-6676][DOCS] Add command for CreateHoodieTableLike (#9441) f138422fcb9 is described below commit f138422fcb94f54d0d0431f81766b64af5a9d519 Author: Rex(Hui) An <bonean...@gmail.com> AuthorDate: Tue Aug 15 10:08:54 2023 +0800 [HUDI-6676][DOCS] Add command for CreateHoodieTableLike (#9441) Co-authored-by: Hussein Awala <huss...@awala.fr> --- website/docs/quick-start-guide.md | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/website/docs/quick-start-guide.md b/website/docs/quick-start-guide.md index a23ce275394..4e6a6e55e5c 100644 --- a/website/docs/quick-start-guide.md +++ b/website/docs/quick-start-guide.md @@ -384,6 +384,68 @@ create table hudi_ctas_cow_pt_tbl2 using hudi location 'file:/tmp/hudi/hudi_tbl/ partitioned by (datestr) as select * from parquet_mngd; ``` +**CREATE TABLE LIKE** + +The `CREATE TABLE LIKE` statement allows you to create a new Hudi table with the same schema and properties from an existing Hudi/hive table. + +:::note +This feature is available in Apache Hudi for Spark 3 and later versions. +::: + +Examples Create a HUDI table from an existing HUDI table + +```sql +# create a source hudi table +create table source_hudi ( + id int, + name string, + price double, + ts long +) using hudi +tblproperties ( + primaryKey = 'id,name', + type = 'cow' + ); + +# create a new hudi table based on the source table +create table target_hudi1 +like source_hudi +using hudi; + +# create a new hudi table based on the source table with override options +create table target_hudi2 +like source_hudi +using hudi +tblproperties (primaryKey = 'id'); + +# create a new external hudi table based on the source table with location +create table target_hudi3 +like source_hudi +using hudi +location 'file:/tmp/hudi/target_hudi3/'; +``` + +Examples Create a HUDI table from an existing parquet table + +```sql +# create a source parquet table +create table source_parquet ( + id int, + name string, + price double, + ts long +) using parquet; + +# create a new hudi table based on the source table +create table target_hudi1 +like source_parquet +using hudi +tblproperties ( + primaryKey = 'id,name', + type = 'cow' +); +``` + **Create Table Properties** Users can set table properties while creating a hudi table. Critical options are listed here.