luoyuxia commented on code in PR #23060:
URL: https://github.com/apache/flink/pull/23060#discussion_r1276249794
##########
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 OR] REPLACE TABLE
+```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 `[CREATE OR] REPLACE TABLE` statement 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.
Review Comment:
```suggestion
* CREATE OR REPLACE TABLE AS SELECT statement: the target table to be
replaced will be created if it does not exist; if it does exist, it'll be
replaced.
```
##########
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 OR] REPLACE TABLE
+```sql
+[CREATE OR] REPLACE TABLE [catalog_name.][db_name.]table_name
+[COMMENT table_comment]
+WITH (key1=val1, key2=val2, ...)
+AS select_query
+```
+
+表也可以通过一个 RTAS 语句中的查询结果来替换(或 创建)并填充数据,RTAS 是一种简单、快捷的替换表并插入数据的方法。
+
+RTAS 有两个部分:SELECT 部分可以是 Flink SQL 支持的任何 [SELECT 查询]({{< ref
"docs/dev/table/sql/queries/overview" >}}), `[CREATE OR] REPLACE`
部分会先删除已经存在的目标表,然后根据从 `SELECT` 查询中获取列信息,创建新的目标表。 与 `CREATE TABLE` 和 `CTAS`
类似,RTAS 要求必须在目标表的 WITH 子句中指定必填的表属性。
+
+示例如下:
+
+```sql
+REPLACE TABLE my_rtas_table
+WITH (
+ 'connector' = 'kafka',
+ ...
+)
+AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;
+```
+
+`[CREATE OR] REPLACE TABLE` 语句等效于使用以下语句先删除表,然后创建表并写入数据:
Review Comment:
等效于 -》等价于
?
##########
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 OR] REPLACE TABLE
+```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:
not actuall in here:`and replace the target table.`
It doesn't always replace the target table
##########
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 OR] REPLACE TABLE
+```sql
+[CREATE OR] REPLACE TABLE [catalog_name.][db_name.]table_name
+[COMMENT table_comment]
+WITH (key1=val1, key2=val2, ...)
+AS select_query
+```
+
+表也可以通过一个 RTAS 语句中的查询结果来替换(或 创建)并填充数据,RTAS 是一种简单、快捷的替换表并插入数据的方法。
Review Comment:
```suggestion
表也可以通过一个 [CREATE OR] REPLACE TABLE(RTAS) 语句中的查询结果来替换(或创建)并填充数据,RTAS
是一种简单快捷的替换表并插入数据的方法。
```
?
##########
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 OR] REPLACE TABLE
+```sql
+[CREATE OR] REPLACE TABLE [catalog_name.][db_name.]table_name
+[COMMENT table_comment]
+WITH (key1=val1, key2=val2, ...)
+AS select_query
+```
+
+表也可以通过一个 RTAS 语句中的查询结果来替换(或 创建)并填充数据,RTAS 是一种简单、快捷的替换表并插入数据的方法。
+
+RTAS 有两个部分:SELECT 部分可以是 Flink SQL 支持的任何 [SELECT 查询]({{< ref
"docs/dev/table/sql/queries/overview" >}}), `[CREATE OR] REPLACE`
部分会先删除已经存在的目标表,然后根据从 `SELECT` 查询中获取列信息,创建新的目标表。 与 `CREATE TABLE` 和 `CTAS`
类似,RTAS 要求必须在目标表的 WITH 子句中指定必填的表属性。
+
+示例如下:
+
+```sql
+REPLACE TABLE my_rtas_table
+WITH (
+ 'connector' = 'kafka',
+ ...
+)
+AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;
+```
+
+`[CREATE OR] REPLACE TABLE` 语句等效于使用以下语句先删除表,然后创建表并写入数据:
Review Comment:
等效于 -》等价于
?
##########
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 OR] REPLACE TABLE
+```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.
Review Comment:
```suggestion
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.
```
##########
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 OR] REPLACE TABLE
+```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 `[CREATE OR] REPLACE TABLE` statement 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.
Review Comment:
```suggestion
* REPLACE TABLE AS SELECT statement: the target table to be replaced must
exist, otherwise, an exception will be thrown.
```
##########
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 OR] REPLACE TABLE
+```sql
+[CREATE OR] REPLACE TABLE [catalog_name.][db_name.]table_name
+[COMMENT table_comment]
+WITH (key1=val1, key2=val2, ...)
+AS select_query
+```
+
+表也可以通过一个 RTAS 语句中的查询结果来替换(或 创建)并填充数据,RTAS 是一种简单、快捷的替换表并插入数据的方法。
Review Comment:
```suggestion
表也可以通过一个 [CREATE OR] REPLACE TABLE(RTAS) 语句中的查询结果来替换(或创建)并填充数据,RTAS
是一种简单快捷的替换表并插入数据的方法。
```
?
##########
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 OR] REPLACE TABLE
+```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 `[CREATE OR] REPLACE TABLE` statement is equivalent to first drop the
table, then create the table and insert the data with the following statement:
Review Comment:
`CREATE OR REPLACE TABLE` is not equivalent to first drop the table if the
table doesn't exist.
--
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]