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

Add approx_percentile in the aggregate functions #2572

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/sql/functions-operators/sql-function-aggregate.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,30 @@ SELECT percentile_disc(0.75) WITHIN GROUP (ORDER BY column1) FROM table1;

If NULL is provided, the function will not calculate a specific percentile and return NULL instead.

---

### `approx_percentile`

:::info Public Preview
This feature is in the public preview stage, meaning it's nearing the final product but is not yet fully stable. If you encounter any issues or have feedback, please contact us through our [Slack channel](https://www.risingwave.com/slack). Your input is valuable in helping us improve the feature. For more information, see our [Public preview feature list](/product-lifecycle/#features-in-the-public-preview-stage).
:::

Returns an approximate value of the specified percentile from a numeric column.

```sql title=Syntax
approx_percentile(DOUBLE percentile [, DOUBLE relative_error]) WITHIN GROUP (ORDER BY percentile_column) -> output_value
```

- `percentile`: The percentile to approximate. It should be between 0 and 1.
- `relative_error`: Optional. Specifies the maximum allowed error in the approximation. Defaults to 0.01 (1%).
- `percentile_column`: The column from which to calculate the percentile. Must be of a numeric type.

This example calculates the 50th percentile of a numeric column with the default relative error:

```sql title=Example
SELECT approx_percentile(0.5) WITHIN GROUP (ORDER BY column1) FROM table1;
```

## Grouping operation functions

Grouping operation functions are used in conjunction with grouping sets to distinguish result rows. The arguments to the `grouping()` function are not actually evaluated, but they must exactly match expressions given in the `GROUP BY` clause of the associated query level.
Expand Down
1 change: 1 addition & 0 deletions src/pages/product-lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ The following is a list of all features in the public preview phase:
| [Manage secrets](/docs/next/manage-secrets/) | 2024.7 | 2.0 |
| [SQL Server CDC source](/docs/next/ingest-from-sqlserver-cdc/) | 2024.8 | 2.0 |
| [Auto schema change in MySQL CDC](/docs/next/ingest-from-mysql-cdc/#automatically-change-schema) | 2024.8 | 2.0 |
| [Approx percentile](/docs/next/sql-function-aggregate/#approx_percentile) | 2024.8 | 2.0 |

This table will be updated regularly to reflect the latest status of features as they progress through the release stages.
Loading