morrySnow commented on code in PR #2055: URL: https://github.com/apache/doris-website/pull/2055#discussion_r1965241932
########## docs/sql-manual/sql-functions/scalar-functions/quantile-functions/quantile-state-empty.md: ########## @@ -22,4 +22,30 @@ specific language governing permissions and limitations under the License. --> +## Description +Return an empty `quantile_state` type column. + +## Syntax +``` +QUANTILE_STATE_EMPTY() +``` + +## Return value + +An empty `quantile_state` type column. + +## Example + +```sql +-------------- +select quantile_percent(quantile_union(quantile_state_empty()), 0) +-------------- + ++-------------------------------------------------------------+ +| quantile_percent(quantile_union(quantile_state_empty()), 0) | ++-------------------------------------------------------------+ +| NULL | ++-------------------------------------------------------------+ +1 row in set (0.12 sec) +``` Review Comment: 按照 quantile-percent 评论中的统一改一下 example 格式 - 查询和结果要分开 - 结果用 text 格式 - 不要最后一行 `x rows...` ########## docs/sql-manual/sql-functions/scalar-functions/quantile-functions/quantile-percent.md: ########## @@ -22,4 +22,52 @@ specific language governing permissions and limitations under the License. --> +## Description +The `QUANTILE_PERCENT` function is used to calculate the quantile value for a given percentage. It takes two parameters: a quantile_state column and a constant floating-point number representing the percentage. The function returns a floating-point number that represents the quantile value at the given percentage position. Review Comment: 章节之间加上空行,防止渲染错误 ########## docs/sql-manual/sql-functions/scalar-functions/quantile-functions/quantile-percent.md: ########## @@ -22,4 +22,52 @@ specific language governing permissions and limitations under the License. --> +## Description +The `QUANTILE_PERCENT` function is used to calculate the quantile value for a given percentage. It takes two parameters: a quantile_state column and a constant floating-point number representing the percentage. The function returns a floating-point number that represents the quantile value at the given percentage position. +## Syntax +``` +QUANTILE_PERCENT(<quantile_state>, <percent>) +``` Review Comment: ````suggestion ```sql QUANTILE_PERCENT(<quantile_state>, <percent>) ``` ```` ########## docs/sql-manual/sql-functions/scalar-functions/quantile-functions/quantile-percent.md: ########## @@ -22,4 +22,52 @@ specific language governing permissions and limitations under the License. --> +## Description +The `QUANTILE_PERCENT` function is used to calculate the quantile value for a given percentage. It takes two parameters: a quantile_state column and a constant floating-point number representing the percentage. The function returns a floating-point number that represents the quantile value at the given percentage position. +## Syntax +``` +QUANTILE_PERCENT(<quantile_state>, <percent>) +``` +## Parameters + +| Parameter | Description | +| -- | -- | +| `<quantile_state>` | The target column.| +| `<percent>` | Target percent.| + +## Return value + +A `Double` type to represent quantile. + +## Example + +```sql +CREATE TABLE IF NOT EXISTS ${tableName_21} ( + `dt` int(11) NULL COMMENT "", + `id` int(11) NULL COMMENT "", + `price` quantile_state QUANTILE_UNION NOT NULL COMMENT "" + ) ENGINE=OLAP + AGGREGATE KEY(`dt`, `id`) + COMMENT "OLAP" + DISTRIBUTED BY HASH(`dt`) BUCKETS 1 + PROPERTIES ("replication_num" = "1"); + +INSERT INTO quantile_state_agg_test VALUES(20220201,0, to_quantile_state(1, 2048)); + +INSERT INTO quantile_state_agg_test VALUES(20220201,1, to_quantile_state(-1, 2048)), + (20220201,1, to_quantile_state(0, 2048)),(20220201,1, to_quantile_state(1, 2048)), + (20220201,1, to_quantile_state(2, 2048)),(20220201,1, to_quantile_state(3, 2048)); + +SELECT dt, id, quantile_percent(quantile_union(price), 0) FROM quantile_state_agg_test GROUP BY dt, id ORDER BY dt, id +-------------- + ++----------+------+--------------------------------------------+ +| dt | id | quantile_percent(quantile_union(price), 0) | ++----------+------+--------------------------------------------+ +| 20220201 | 0 | 1 | +| 20220201 | 1 | -1 | ++----------+------+--------------------------------------------+ +2 rows in set (0.42 sec) +``` Review Comment: ````suggestion SELECT dt, id, quantile_percent(quantile_union(price), 0) FROM quantile_state_agg_test GROUP BY dt, id ORDER BY dt, id ``` ```text +----------+------+--------------------------------------------+ | dt | id | quantile_percent(quantile_union(price), 0) | +----------+------+--------------------------------------------+ | 20220201 | 0 | 1 | | 20220201 | 1 | -1 | +----------+------+--------------------------------------------+ ``` ```` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org