luoyuxia commented on code in PR #22927:
URL: https://github.com/apache/flink/pull/22927#discussion_r1254320655
##########
docs/content/docs/dev/table/sql/alter.md:
##########
@@ -354,6 +357,12 @@ ALTER TABLE MyTable ADD (
PRIMARY KEY (id) NOT ENFORCED,
WATERMARK FOR ts AS ts - INTERVAL '3' SECOND
);
+
+-- add a new partition
+ALTER TABLE MyTable ADD PARTITION (p1=1,p2='a') with ('k1'='v1');
+
+-- add two new partitions
+ALTER TABLE MyTable ADD PARTITION (p1=1,p2='a') with ('k1'='v1'), PARTITION
(p1=1,p2='b') with ('k2'='v2');
Review Comment:
dito
##########
docs/content.zh/docs/dev/table/sql/alter.md:
##########
@@ -297,9 +297,9 @@ Flink SQL> SHOW TABLES;
当前支持的 ALTER TABLE 语法如下
```text
ALTER TABLE [IF EXISTS] table_name {
- ADD { <schema_component> | (<schema_component> [, ...]) }
+ ADD { <schema_component> | (<schema_component> [, ...]) | [IF NOT EXISTS]
<partition_component> [, ...]}
Review Comment:
```suggestion
ADD { <schema_component> | (<schema_component> [, ...]) | [IF NOT
EXISTS] <partition_component> [<partition_component> ...]}
```
##########
docs/content.zh/docs/dev/table/sql/alter.md:
##########
@@ -329,30 +329,39 @@ ALTER TABLE [IF EXISTS] table_name {
<computed_column_definition>:
AS computed_column_expression
+
+<partition_component>:
+ PARTITION (key1=val1, key2=val2, ...) [WITH (key1=val1, key2=val2, ...)]
```
**IF EXISTS**
若表不存在,则不进行任何操作。
### ADD
-使用 `ADD` 语句向已有表中增加 [columns]({{< ref "docs/dev/table/sql/create" >}}#columns),
[constraints]({{< ref "docs/dev/table/sql/create"
>}}#primary-key),[watermark]({{< ref "docs/dev/table/sql/create" >}}#watermark)。
+使用 `ADD` 语句向已有表中增加 [columns]({{< ref "docs/dev/table/sql/create" >}}#columns),
[constraints]({{< ref "docs/dev/table/sql/create"
>}}#primary-key),[watermark]({{< ref "docs/dev/table/sql/create"
>}}#watermark), [partitions]({{< ref "docs/dev/table/sql/create"
>}}#partitioned-by)。
向表新增列时可通过 `FIRST` or `AFTER col_name` 指定位置,不指定位置时默认追加在最后。
`ADD` 语句示例如下。
```sql
--- add a new column
+-- 新增一列
ALTER TABLE MyTable ADD category_id STRING COMMENT 'identifier of the
category';
--- add columns, constraint, and watermark
+-- 新增列,主键和 watermark
ALTER TABLE MyTable ADD (
log_ts STRING COMMENT 'log timestamp string' FIRST,
ts AS TO_TIMESTAMP(log_ts) AFTER log_ts,
PRIMARY KEY (id) NOT ENFORCED,
WATERMARK FOR ts AS ts - INTERVAL '3' SECOND
);
+
+-- 新增一个分区
+ALTER TABLE MyTable ADD PARTITION (p1=1,p2='a') with ('k1'='v1');
+
+-- 新增两个分区
+ALTER TABLE MyTable ADD PARTITION (p1=1,p2='a') with ('k1'='v1'), PARTITION
(p1=1,p2='b') with ('k2'='v2');
Review Comment:
```suggestion
ALTER TABLE MyTable ADD PARTITION (p1=1,p2='a') with ('k1'='v1') PARTITION
(p1=1,p2='b') with ('k2'='v2');
```
##########
docs/content/docs/dev/table/sql/alter.md:
##########
@@ -298,9 +298,9 @@ Flink SQL> SHOW TABLES;
The following grammar gives an overview about the available syntax:
```text
ALTER TABLE [IF EXISTS] table_name {
- ADD { <schema_component> | (<schema_component> [, ...]) }
+ ADD { <schema_component> | (<schema_component> [, ...]) | [IF NOT EXISTS]
<partition_component> [, ...]}
Review Comment:
dito
##########
docs/content.zh/docs/dev/table/sql/show.md:
##########
@@ -740,6 +740,65 @@ show columns from orders not like '%_r';
4 rows in set
```
+## SHOW PARTITIONS
+
+```sql
+SHOW PARTITIONS [[catalog_name.]database.]<table_name> [ PARTITION
<partition_spec>]
+
+<partition_spec>:
+ (key1=val1, key2=val2, ...)
+```
+
+展示给定分区表的所有分区。
+
+**PARTITION**
+根据可选的 `PARTITION` 语句展示给定分区表中在指定的 `<partition_spec>` 分区下的所有分区。
+
+### SHOW PARTITIONS 示例
+
+假定在 `catalog1` catalog 中的 `database1` 数据库中有名为 `table1` 的分区表,其包含的所有分区如下所示:
+
+```sql
++---------+-----------------------------+
+| id | date |
++---------+-----------------------------+
+| 1001 | 2020-01-01 |
+| 1002 | 2020-01-01 |
+| 1002 | 2020-01-02 |
++---------+-----------------------------+
+```
+
+- 显示指定分区表中的所有分区。
+
+```sql
+show partitions table1;
+-- show partitions database1.table1;
+-- show partitions catalog1.database1.table1;
++---------+-----------------------------+
+| id | date |
++---------+-----------------------------+
+| 1001 | 2020-01-01 |
+| 1002 | 2020-01-01 |
+| 1002 | 2020-01-02 |
++---------+-----------------------------+
+3 rows in set
+```
+
+- 显示指定分区表和指定分区下的所有分区。
Review Comment:
nit:
显示指定分区表和指定分区下的所有分区 -> 显示指定分区表在指定分区下的所有分区
?
##########
docs/content/docs/dev/table/sql/show.md:
##########
@@ -740,6 +741,65 @@ show columns from orders not like '%_r';
4 rows in set
```
+## SHOW PARTITIONS
+
+```sql
+SHOW PARTITIONS [[catalog_name.]database.]<table_name> [ PARTITION
<partition_spec>]
+
+<partition_spec>:
+ (key1=val1, key2=val2, ...)
+```
+
+Show all partitions of the partitioned table with the given table name and
optional partition clause.
+
+**PARTITION**
+Show all partitions of the partitioned table with the given table name and
optional `PARTITION` clause, which are under the provided <partition_spec>.
Review Comment:
Seem there's a grammar issue it this sentence, I would like to change it to:
Show all the partitions which are under the provided <partition_spec>.
--
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]