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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 90ae8dcf01 [typo](docs)supplement the document content (#16884)
90ae8dcf01 is described below

commit 90ae8dcf01f31e5f5ab0a41aa5098aa5235cf065
Author: yagagagaga <zhangminkefromflyd...@gmail.com>
AuthorDate: Fri Feb 17 20:55:34 2023 +0800

    [typo](docs)supplement the document content (#16884)
    
    * [typo](docs)supplement the document content
    
    * Update grouping.md
    
    Add space before and after English letters in CN docs and keep the English 
case consistent.
    
    * Update grouping.md
    
    Change the Chinese title to English
---
 .../sql-functions/aggregate-functions/grouping.md  | 90 +++++++++++++++++----
 .../sql-functions/aggregate-functions/grouping.md  | 91 ++++++++++++++++++----
 2 files changed, 147 insertions(+), 34 deletions(-)

diff --git 
a/docs/en/docs/sql-manual/sql-functions/aggregate-functions/grouping.md 
b/docs/en/docs/sql-manual/sql-functions/aggregate-functions/grouping.md
index e8e5d53659..e642ebd14e 100755
--- a/docs/en/docs/sql-manual/sql-functions/aggregate-functions/grouping.md
+++ b/docs/en/docs/sql-manual/sql-functions/aggregate-functions/grouping.md
@@ -25,26 +25,82 @@ under the License.
 -->
 
 ## GROUPING
-### description
-#### Syntax
 
-`GROUPING(expr)`
+Indicates whether a specified column expression in a `GROUP BY` list is 
aggregated or not. `GROUPING` returns 1 for aggregated or 0 for not aggregated 
in the result set. `GROUPING` can be used only in the `SELECT <select> list`, 
`HAVING`, and `ORDER BY` clauses when `GROUP BY` is specified.
 
-GROUPING is used in SQL statements containing CUBE or ROLLUP statements. When 
the data rows in the result set are generated by CUBE or ROLLUP operations, 
this function returns 1. Otherwise, it returns 0.
+### Syntax
 
-### example
+```sql
+GROUPING( <column_expression> )
 ```
-MySQL > SELECT COL1,GROUPING(COL2) AS 'Grouping' FROM tbl GROUP BY ROLLUP 
(COL1, COL2);
-+------+----------+
-| COL1 | Grouping |
-+------+----------+
-| NULL |        1 |
-| 2.20 |        1 |
-| 2.20 |        0 |
-| 1.10 |        1 |
-| 1.10 |        0 |
-+------+----------+
+
+### Arguments
+
+`<column_expression>`
+Is a column or an expression that contains a column in a `GROUP BY` clause.
+
+### Return Types
+
+BIGINT
+
+### Remarks
+
+`GROUPING` is used to distinguish the null values that are returned by 
`ROLLUP`, `CUBE` or `GROUPING SETS` from standard null values. The `NULL` 
returned as the result of a `ROLLUP`, `CUBE` or `GROUPING SETS` operation is a 
special use of `NULL`. This acts as a column placeholder in the result set and 
means all.
+
+### Example
+
+The following example groups `camp` and aggregates `occupation` amounts in the 
database. The `GROUPING` function is applied to the `camp` column.
+
+```sql
+CREATE TABLE `roles` (
+  role_id       INT,
+  occupation    VARCHAR(32),
+  camp          VARCHAR(32),
+  register_time DATE
+)
+UNIQUE KEY(role_id)
+DISTRIBUTED BY HASH(role_id) BUCKETS 1
+PROPERTIES (
+  "replication_allocation" = "tag.location.default: 1"
+);
+
+INSERT INTO `roles` VALUES
+(0, 'who am I', NULL, NULL),
+(1, 'mage', 'alliance', '2018-12-03 16:11:28'),
+(2, 'paladin', 'alliance', '2018-11-30 16:11:28'),
+(3, 'rogue', 'horde', '2018-12-01 16:11:28'),
+(4, 'priest', 'alliance', '2018-12-02 16:11:28'),
+(5, 'shaman', 'horde', NULL),
+(6, 'warrior', 'alliance', NULL),
+(7, 'warlock', 'horde', '2018-12-04 16:11:28'),
+(8, 'hunter', 'horde', NULL);
+
+SELECT 
+  camp, 
+  COUNT(occupation) AS 'occ_cnt',
+  GROUPING(camp)    AS 'grouping'
+FROM
+   `roles`
+GROUP BY
+  ROLLUP(camp); -- CUBE(camp) and GROUPING SETS((camp)) also can work;
+```
+
+The result set shows two null value under `camp`. The first NULL is in the 
summary row added by the `ROLLUP` operation. The summary row shows the 
occupation counts for all `camp` groups and is indicated by 1 in the Grouping 
column. The second NULL represents the group of null values from this column in 
the table.
+
+Here is the result set.
+
+```log
++----------+---------+----------+
+| camp     | occ_cnt | grouping |
++----------+---------+----------+
+| NULL     |       9 |        1 |
+| NULL     |       1 |        0 |
+| alliance |       4 |        0 |
+| horde    |       4 |        0 |
++----------+---------+----------+
+4 rows in set (0.01 sec)
 ```
 
-### keywords
-GROUPING
+### See Also
+
+[GROUPING_ID](./grouping_id.md)
diff --git 
a/docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/grouping.md 
b/docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/grouping.md
index e990ab2c30..5943205c14 100755
--- a/docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/grouping.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/grouping.md
@@ -25,25 +25,82 @@ under the License.
 -->
 
 ## GROUPING
-### description
-#### Syntax
 
-`GROUPING(expr)`
+用在含有 CUBE、ROLLUP 或 GROUPING SETS 的 SQL 语句中,用于表示进行 CUBE、ROLLUP 或 GROUPING SETS 
操作的列是否汇总。当结果集中的数据行是 CUBE、ROLLUP 或 GROUPING SETS 操作产生的汇总结果时,该函数返回 1,否则返回 
0。GROUPING 函数可以在 `SELECT`、`HAVING` 和 `ORDER BY` 子句当中使用。
 
-GROUPING用在含有CUBE 或 ROLLUP 语句的SQL语句中,当结果集中的数据行是由CUBE 或 ROLLUP 
运算产生的则该函数返回1,否则返回0。
+### Syntax
 
-### example
+```sql
+GROUPING( <column_expression> )
 ```
-MySQL > SELECT COL1,GROUPING(COL2) AS 'Grouping' FROM tbl GROUP BY ROLLUP 
(COL1, COL2);
-+------+----------+
-| COL1 | Grouping |
-+------+----------+
-| NULL |        1 |
-| 2.20 |        1 |
-| 2.20 |        0 |
-| 1.10 |        1 |
-| 1.10 |        0 |
-+------+----------+
+
+### Arguments
+
+`<column_expression>`
+是在 `GROUP BY` 子句中包含的列或表达式。
+
+### Return Types
+
+BIGINT
+
+### Remarks
+
+`ROLLUP`、`CUBE` 或 `GROUPING SETS` 操作返回的汇总结果,会用 NULL 充当被分组的字段的值。因此,`GROUPING` 
通常用于区分 `ROLLUP`、`CUBE` 或 `GROUPING SETS` 返回的空值与表中的空值。
+
+### Example
+
+下面的例子使用 `camp` 列进行分组操作,并对 `occupation` 的数量进行汇总,`GROUPING` 函数作用于 `camp` 列。
+
+```sql
+CREATE TABLE `roles` (
+  role_id       INT,
+  occupation    VARCHAR(32),
+  camp          VARCHAR(32),
+  register_time DATE
+)
+UNIQUE KEY(role_id)
+DISTRIBUTED BY HASH(role_id) BUCKETS 1
+PROPERTIES (
+  "replication_allocation" = "tag.location.default: 1"
+);
+
+INSERT INTO `roles` VALUES
+(0, 'who am I', NULL, NULL),
+(1, 'mage', 'alliance', '2018-12-03 16:11:28'),
+(2, 'paladin', 'alliance', '2018-11-30 16:11:28'),
+(3, 'rogue', 'horde', '2018-12-01 16:11:28'),
+(4, 'priest', 'alliance', '2018-12-02 16:11:28'),
+(5, 'shaman', 'horde', NULL),
+(6, 'warrior', 'alliance', NULL),
+(7, 'warlock', 'horde', '2018-12-04 16:11:28'),
+(8, 'hunter', 'horde', NULL);
+
+SELECT 
+  camp, 
+  COUNT(occupation) AS 'occ_cnt',
+  GROUPING(camp)    AS 'grouping'
+FROM
+   `roles`
+GROUP BY
+  ROLLUP(camp); -- CUBE(camp) 和 GROUPING SETS((camp)) 同样也有效;
+```
+
+结果集在 `camp` 列下有两个 NULL 值,第一个 NULL 值表示 `ROLLUP` 操作的列的汇总结果,这一行的 `occ_cnt` 列表示所有 
`camp` 的 `occupation` 的计数结果,在 `grouping` 函数中返回 1。第二个 NULL 表示 `camp` 列中本来就存在的 
NULL 值。
+
+结果集如下:
+
+```log
++----------+---------+----------+
+| camp     | occ_cnt | grouping |
++----------+---------+----------+
+| NULL     |       9 |        1 |
+| NULL     |       1 |        0 |
+| alliance |       4 |        0 |
+| horde    |       4 |        0 |
++----------+---------+----------+
+4 rows in set (0.01 sec)
 ```
-### keywords
-GROUPING
+
+### See Also
+
+[GROUPING_ID](./grouping_id.md)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to