luoyuxia commented on code in PR #23060:
URL: https://github.com/apache/flink/pull/23060#discussion_r1273468797
##########
docs/content.zh/docs/dev/table/sql/create.md:
##########
@@ -557,6 +558,58 @@ INSERT INTO my_ctas_table SELECT id, name, age FROM
source_table WHERE mod(id, 1
{{< top >}}
+## CREATE TABLE [USING]
Review Comment:
dito
##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -557,6 +558,58 @@ INSERT INTO my_ctas_table SELECT id, name, age FROM
source_table WHERE mod(id, 1
{{< top >}}
+## CREATE TABLE [USING]
+```sql
+[CREATE OR] REPLACE TABLE [catalog_name.][db_name.]table_name
+[COMMENT table_comment]
+WITH (key1=val1, key2=val2, ...)
+AS select_query
+```
+Tables can also be replaced(or created) and populated by the results of a
query in one replace-table-as-select (RTAS) statement. RTAS is the simplest
and fastest way to replace and insert data into a table with a single command.
+
+There are two parts in RTAS, the SELECT part can be any [SELECT query]({{< ref
"docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL. The `[CREATE
OR] REPLACE` part takes the resulting schema from the `SELECT` part and replace
the target table. Similar to `CREATE TABLE` and `CTAS`, RTAS requires the
required options of the target table must be specified in WITH clause.
+
+Consider the example statement below:
+
+```sql
+REPLACE TABLE my_rtas_table
+WITH (
+ 'connector' = 'kafka',
+ ...
+)
+AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;
+```
+
+The resulting table `my_rtas_table` is equivalent to first drop the table,
then create the table and insert the data with the following statement:
Review Comment:
Should be the statement is is equivalent to instead of the resulting table.
WDYT?
##########
docs/content.zh/docs/dev/table/sql/create.md:
##########
@@ -33,6 +33,7 @@ CREATE 语句用于向当前或指定的 [Catalog]({{< ref "docs/dev/table/catal
目前 Flink SQL 支持下列 CREATE 语句:
- CREATE TABLE
+- CREATE TABLE [USING]
Review Comment:
Why `CREATE TABLE [USING]`?
##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -557,6 +558,58 @@ INSERT INTO my_ctas_table SELECT id, name, age FROM
source_table WHERE mod(id, 1
{{< top >}}
+## CREATE TABLE [USING]
+```sql
+[CREATE OR] REPLACE TABLE [catalog_name.][db_name.]table_name
+[COMMENT table_comment]
+WITH (key1=val1, key2=val2, ...)
+AS select_query
+```
+Tables can also be replaced(or created) and populated by the results of a
query in one replace-table-as-select (RTAS) statement. RTAS is the simplest
and fastest way to replace and insert data into a table with a single command.
+
+There are two parts in RTAS, the SELECT part can be any [SELECT query]({{< ref
"docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL. The `[CREATE
OR] REPLACE` part takes the resulting schema from the `SELECT` part and replace
the target table. Similar to `CREATE TABLE` and `CTAS`, RTAS requires the
required options of the target table must be specified in WITH clause.
+
+Consider the example statement below:
+
+```sql
+REPLACE TABLE my_rtas_table
+WITH (
+ 'connector' = 'kafka',
+ ...
+)
+AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;
+```
+
+The resulting table `my_rtas_table` is equivalent to first drop the table,
then create the table and insert the data with the following statement:
+```sql
+DROP TABLE my_rtas_table;
+
+CREATE TABLE my_rtas_table (
+ id BIGINT,
+ name STRING,
+ age INT
+) WITH (
+ 'connector' = 'kafka',
+ ...
+);
+
+INSERT INTO my_rtas_table SELECT id, name, age FROM source_table WHERE mod(id,
10) = 0;
+```
+
+**Note** RTAS has the following semantic:
+* REPLACE TABLE AS SELECT statement, the target table to be replaced must
exist or an exception is thrown.
+* CREATE OR REPLACE TABLE AS SELECT statement, the target table to be replaced
is created if it does not exist; if it does exist, it is replaced.
+
+**Note** RTAS has these restrictions:
+
+Does not support replacing a temporary table yet.
Review Comment:
`* Does not support creating a temporary table yet.`.
##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -557,6 +558,58 @@ INSERT INTO my_ctas_table SELECT id, name, age FROM
source_table WHERE mod(id, 1
{{< top >}}
+## CREATE TABLE [USING]
+```sql
+[CREATE OR] REPLACE TABLE [catalog_name.][db_name.]table_name
+[COMMENT table_comment]
+WITH (key1=val1, key2=val2, ...)
+AS select_query
+```
+Tables can also be replaced(or created) and populated by the results of a
query in one replace-table-as-select (RTAS) statement. RTAS is the simplest
and fastest way to replace and insert data into a table with a single command.
+
+There are two parts in RTAS, the SELECT part can be any [SELECT query]({{< ref
"docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL. The `[CREATE
OR] REPLACE` part takes the resulting schema from the `SELECT` part and replace
the target table. Similar to `CREATE TABLE` and `CTAS`, RTAS requires the
required options of the target table must be specified in WITH clause.
Review Comment:
```suggestion
There are two parts in RTAS: the SELECT part can be any [SELECT query]({{<
ref "docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL, the
`[CREATE OR] REPLACE` part takes the resulting schema from the `SELECT` part
and replace the target table. Similar to `CREATE TABLE` and `CTAS`, RTAS
requires the required options of the target table must be specified in WITH
clause.
```
?
##########
docs/content.zh/docs/dev/table/sql/create.md:
##########
@@ -557,6 +558,58 @@ INSERT INTO my_ctas_table SELECT id, name, age FROM
source_table WHERE mod(id, 1
{{< top >}}
+## CREATE TABLE [USING]
Review Comment:
Now, I'm wondering can we just put RTAS unser `AS select_statement` just
as`CTAS`? For me, `RTAS` has no much difference with `CTAS`.
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]