Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quantile serias scalar function #2055

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zhiqiang-hhhh
Copy link
Contributor

Versions

  • dev
  • 3.0
  • 2.1
  • 2.0

Languages

  • Chinese
  • English

Docs Checklist

  • Checked by AI
  • Test Cases Built

Comment on lines +25 to +26
## 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

章节之间加上空行,防止渲染错误

Comment on lines +28 to +30
```
QUANTILE_PERCENT(<quantile_state>, <percent>)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
QUANTILE_PERCENT(<quantile_state>, <percent>)
```
```sql
QUANTILE_PERCENT(<quantile_state>, <percent>)
```

Comment on lines +61 to +71
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)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
```
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 |
+----------+------+--------------------------------------------+
```

Comment on lines +40 to +51
```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)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照 quantile-percent 评论中的统一改一下 example 格式

  • 查询和结果要分开
  • 结果用 text 格式
  • 不要最后一行 x rows...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants