lsyldliu commented on code in PR #20653:
URL: https://github.com/apache/flink/pull/20653#discussion_r973930911


##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -184,6 +184,9 @@ CREATE TABLE [IF NOT EXISTS] 
[catalog_name.][db_name.]table_name
  | { INCLUDING | EXCLUDING | OVERWRITING } { GENERATED | OPTIONS | WATERMARKS 
} 
 }[, ...]
 
+<select_query>:
+The table is populated using the data from the select statement.

Review Comment:
   ```suggestion
   The table is populated using the data from the select query.
   ```



##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -513,6 +516,52 @@ If you provide no like options, `INCLUDING ALL OVERWRITING 
OPTIONS` will be used
 
 **NOTE** The `source_table` can be a compound identifier. Thus, it can be a 
table from a different catalog or database: e.g. `my_catalog.my_db.MyTable` 
specifies table `MyTable` from catalog `MyCatalog` and database `my_db`; 
`my_db.MyTable` specifies table `MyTable` from current catalog and database 
`my_db`.
 
+### `AS`
+
+Tables can also be created and populated by the results of a query in one 
create-table-as-select (CTAS) statement. 
+CTAS is the simplest and fastest way to create and insert data into a table 
with a single command.
+
+There are two parts in CTAS, the SELECT part can be any [SELECT statement]({{< 
ref "docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL. 
+The CREATE part of the CTAS takes the resulting schema from the SELECT part 
and creates the target table with other table properties such as the connector 
and URL. 
+Similar to CREATE TABLE, CTAS requires the required options of the 
corresponding connector must be specified in WITH clause.
+
+**NOTE** If using an in-memory catalog, the user must ensure that external 
storage already exists; If using an external catalog, then flink will create 
table from the external catalog, such as HiveCatalog.
+
+Consider the example statement below:
+
+```sql
+CREATE TABLE my_ctas_table
+WITH (
+    'connector' = 'kafka',
+    ...
+)
+AS
+SELECT id, name, age FROM test WHERE mod(id, 10) = 0;
+```
+
+The resulting table `my_ctas_table` will be equivalent to create the table and 
insert the data with the following statement:
+```sql
+CREATE TABLE my_ctas_table (
+    id BIGINT,
+    name STRING,
+    age INT
+) WITH (
+    'connector' = 'kafka',
+    ...
+);
+ 
+INSERT INTO my_ctas_table SELECT id, name, age FROM test WHERE mod(id, 10) = 0;
+```
+
+**Note** CTAS has these restrictions:
+* Does not support creating a temporary table yet.
+* Does not support specifying explicit columns yet.
+* Does not support specifying explicit watermark yet.
+* Does not support creating partitioned table yet.
+* Does not support specifying primary key constraints yet.
+
+**Note** The CTAS clause is currently non-atomicity and does not drop the 
target table when the job's final status is FAILED/CANCELED.

Review Comment:
   ```suggestion
   **Note** The target table created by CTAS is non-atomic currently, the table 
won't be dropped automatically if occur errors while inserting data into the 
table.
   ```



##########
docs/content.zh/docs/dev/table/sql/create.md:
##########
@@ -186,6 +186,9 @@ CREATE TABLE [IF NOT EXISTS] 
[catalog_name.][db_name.]table_name
  | { INCLUDING | EXCLUDING | OVERWRITING } { GENERATED | OPTIONS | WATERMARKS 
} 
 }[, ...]
 
+<select_query>:
+使用来自SELECT语句的数据填充表。

Review Comment:
   Ditto. In addition, please leave a space between Chinese and English 
characters.



##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -513,6 +516,52 @@ If you provide no like options, `INCLUDING ALL OVERWRITING 
OPTIONS` will be used
 
 **NOTE** The `source_table` can be a compound identifier. Thus, it can be a 
table from a different catalog or database: e.g. `my_catalog.my_db.MyTable` 
specifies table `MyTable` from catalog `MyCatalog` and database `my_db`; 
`my_db.MyTable` specifies table `MyTable` from current catalog and database 
`my_db`.
 
+### `AS`
+
+Tables can also be created and populated by the results of a query in one 
create-table-as-select (CTAS) statement. 
+CTAS is the simplest and fastest way to create and insert data into a table 
with a single command.
+
+There are two parts in CTAS, the SELECT part can be any [SELECT statement]({{< 
ref "docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL. 
+The CREATE part of the CTAS takes the resulting schema from the SELECT part 
and creates the target table with other table properties such as the connector 
and URL. 
+Similar to CREATE TABLE, CTAS requires the required options of the 
corresponding connector must be specified in WITH clause.
+
+**NOTE** If using an in-memory catalog, the user must ensure that external 
storage already exists; If using an external catalog, then flink will create 
table from the external catalog, such as HiveCatalog.
+
+Consider the example statement below:
+
+```sql
+CREATE TABLE my_ctas_table
+WITH (
+    'connector' = 'kafka',
+    ...
+)
+AS

Review Comment:
   ```suggestion
   AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;
   ```



##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -513,6 +516,52 @@ If you provide no like options, `INCLUDING ALL OVERWRITING 
OPTIONS` will be used
 
 **NOTE** The `source_table` can be a compound identifier. Thus, it can be a 
table from a different catalog or database: e.g. `my_catalog.my_db.MyTable` 
specifies table `MyTable` from catalog `MyCatalog` and database `my_db`; 
`my_db.MyTable` specifies table `MyTable` from current catalog and database 
`my_db`.
 
+### `AS`
+
+Tables can also be created and populated by the results of a query in one 
create-table-as-select (CTAS) statement. 
+CTAS is the simplest and fastest way to create and insert data into a table 
with a single command.
+
+There are two parts in CTAS, the SELECT part can be any [SELECT statement]({{< 
ref "docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL. 
+The CREATE part of the CTAS takes the resulting schema from the SELECT part 
and creates the target table with other table properties such as the connector 
and URL. 
+Similar to CREATE TABLE, CTAS requires the required options of the 
corresponding connector must be specified in WITH clause.
+
+**NOTE** If using an in-memory catalog, the user must ensure that external 
storage already exists; If using an external catalog, then flink will create 
table from the external catalog, such as HiveCatalog.
+
+Consider the example statement below:
+
+```sql
+CREATE TABLE my_ctas_table
+WITH (
+    'connector' = 'kafka',
+    ...
+)
+AS
+SELECT id, name, age FROM test WHERE mod(id, 10) = 0;
+```
+
+The resulting table `my_ctas_table` will be equivalent to create the table and 
insert the data with the following statement:
+```sql
+CREATE TABLE my_ctas_table (
+    id BIGINT,
+    name STRING,
+    age INT
+) WITH (
+    'connector' = 'kafka',
+    ...
+);
+ 
+INSERT INTO my_ctas_table SELECT id, name, age FROM test WHERE mod(id, 10) = 0;

Review Comment:
   ```suggestion
   INSERT INTO my_ctas_table SELECT id, name, age FROM source_table WHERE 
mod(id, 10) = 0;
   ```



##########
docs/content/docs/dev/table/sql/create.md:
##########
@@ -513,6 +516,52 @@ If you provide no like options, `INCLUDING ALL OVERWRITING 
OPTIONS` will be used
 
 **NOTE** The `source_table` can be a compound identifier. Thus, it can be a 
table from a different catalog or database: e.g. `my_catalog.my_db.MyTable` 
specifies table `MyTable` from catalog `MyCatalog` and database `my_db`; 
`my_db.MyTable` specifies table `MyTable` from current catalog and database 
`my_db`.
 
+### `AS`
+
+Tables can also be created and populated by the results of a query in one 
create-table-as-select (CTAS) statement. 
+CTAS is the simplest and fastest way to create and insert data into a table 
with a single command.
+
+There are two parts in CTAS, the SELECT part can be any [SELECT statement]({{< 
ref "docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL. 

Review Comment:
   I think this would be more clear, WDYT?
   
   ```
   Tables can also be created and populated by the results of a query in one 
create-table-as-select (CTAS) statement. CTAS is the simplest and fastest way 
to create and insert data into a table with a single command.
   
   There are two parts in CTAS, the SELECT part can be any [SELECT query]({{< 
ref "docs/dev/table/sql/queries/overview" >}}) supported by Flink SQL. The 
CREATE part takes the resulting schema from the SELECT part and creates the 
target table. Similar to `CREATE TABLE`, CTAS requires the required options of 
the target table must be specified in WITH clause.
   
   Creating the target table of CTAS depends on Catalog, so if using the 
built-in memory Catalog, users must ensure that the table already exists in 
external storage. If using other catalogs such as hive Catalog, the target 
table will be created by Catalog automatically.
   
   ```



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to