You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by hu...@apache.org on 2022/03/02 20:01:17 UTC

[spark] branch branch-3.1 updated: [MINOR][SQL][DOCS] Add more examples to sql-ref-syntax-ddl-create-table-datasource

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

huaxingao pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 6ec3045  [MINOR][SQL][DOCS] Add more examples to sql-ref-syntax-ddl-create-table-datasource
6ec3045 is described below

commit 6ec30452b87f39b1a22ddf0edb7f83ec94cc906c
Author: Yuming Wang <yu...@ebay.com>
AuthorDate: Wed Mar 2 11:57:38 2022 -0800

    [MINOR][SQL][DOCS] Add more examples to sql-ref-syntax-ddl-create-table-datasource
    
    ### What changes were proposed in this pull request?
    
    Add more examples to sql-ref-syntax-ddl-create-table-datasource:
    1. Create partitioned and bucketed table through CTAS.
    2. Create bucketed table through CTAS and CTE
    
    ### Why are the changes needed?
    
    Improve doc.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Manual test.
    
    Closes #35712 from wangyum/sql-ref-syntax-ddl-create-table-datasource.
    
    Authored-by: Yuming Wang <yu...@ebay.com>
    Signed-off-by: huaxingao <hu...@apple.com>
    (cherry picked from commit 829d7fb045e47f1ddd43f2645949ea8257ca330d)
    Signed-off-by: huaxingao <hu...@apple.com>
---
 docs/sql-ref-syntax-ddl-create-table-datasource.md | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/docs/sql-ref-syntax-ddl-create-table-datasource.md b/docs/sql-ref-syntax-ddl-create-table-datasource.md
index ba0516a..9fa5dcb 100644
--- a/docs/sql-ref-syntax-ddl-create-table-datasource.md
+++ b/docs/sql-ref-syntax-ddl-create-table-datasource.md
@@ -132,6 +132,23 @@ CREATE TABLE student (id INT, name STRING, age INT)
     USING CSV
     PARTITIONED BY (age)
     CLUSTERED BY (Id) INTO 4 buckets;
+
+--Create partitioned and bucketed table through CTAS
+CREATE TABLE student_partition_bucket
+    USING parquet
+    PARTITIONED BY (age)
+    CLUSTERED BY (id) INTO 4 buckets
+    AS SELECT * FROM student;
+
+--Create bucketed table through CTAS and CTE
+CREATE TABLE student_bucket
+    USING parquet
+    CLUSTERED BY (id) INTO 4 buckets (
+    WITH tmpTable AS (
+        SELECT * FROM student WHERE id > 100
+    )
+    SELECT * FROM tmpTable
+);
 ```
 
 ### Related Statements

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org