You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/sql-reference/20-sql-functions/07-aggregate-functions/aggregate-histogram.md
+52-39
Original file line number
Diff line number
Diff line change
@@ -5,43 +5,37 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
5
5
6
6
<FunctionDescriptiondescription="Introduced or updated: v1.2.377"/>
7
7
8
-
Computes the distribution of the data. It uses an "equal height" bucketing strategy to generate the histogram. The result of the function returns an empty or Json string.
8
+
Generates a data distribution histogram using an "equal height" bucketing strategy.
9
9
10
10
## Syntax
11
11
12
12
```sql
13
13
HISTOGRAM(<expr>)
14
-
HISTOGRAM(<expr> [, max_num_buckets])
15
-
```
16
-
17
-
`max_num_buckets` means the maximum number of buckets that can be used, by default it is 128.
|`expr`| The data type of `expr` should be sortable. |
23
+
|`max_num_buckets`| Optional positive integer specifying the maximum number of buckets. Default is 128.|
37
24
38
25
## Return Type
39
26
40
-
the Nullable String type
27
+
Returns either an empty string or a JSON object with the following structure:
41
28
42
-
## Example
29
+
-**buckets**: List of buckets with detailed information:
30
+
-**lower**: Lower bound of the bucket.
31
+
-**upper**: Upper bound of the bucket.
32
+
-**count**: Number of elements in the bucket.
33
+
-**pre_sum**: Cumulative count of elements up to the current bucket.
34
+
-**ndv**: Number of distinct values in the bucket.
43
35
44
-
**Create a Table and Insert Sample Data**
36
+
## Examples
37
+
38
+
This example shows how the HISTOGRAM function analyzes the distribution of `c_int` values in the `histagg` table, returning bucket boundaries, distinct value counts, element counts, and cumulative counts:
0 commit comments