Skip to content

Commit

Permalink
Merge branch 'main' into databend-driver-python
Browse files Browse the repository at this point in the history
  • Loading branch information
soyeric128 authored Jan 22, 2025
2 parents 96a8595 + 07f23b7 commit a9039ec
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 43 deletions.
5 changes: 3 additions & 2 deletions docs/en/guides/10-deploy/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
title: Self-Hosted Databend
---

import IndexOverviewList from '@site/src/components/IndexOverviewList';

These guides provide detailed instructions for deploying and upgrading Databend, catering to both the [Databend Community Edition](../00-overview/00-editions/00-dce/index.md) and [Databend Enterprise Edition](../00-overview/00-editions/01-dee/index.md).
These guides provide detailed instructions for deploying and upgrading Databend, catering to both the [Databend Community Edition](../00-overview/00-editions/00-dce.md) and [Databend Enterprise Edition](../00-overview/00-editions/01-dee/index.md).

:::tip try out databend cloud
Say goodbye to deployment and upgrade hassles – Databend Cloud manages these intricacies for you, freeing up your focus for what truly matters. Ready to experience the ease? [Sign up here](https://www.databend.com/apply/?r=doc-card).
:::

<IndexOverviewList />
<IndexOverviewList />
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,37 @@ import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="Introduced or updated: v1.2.377"/>

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.
Generates a data distribution histogram using an "equal height" bucketing strategy.

## Syntax

```sql
HISTOGRAM(<expr>)
HISTOGRAM(<expr> [, max_num_buckets])
```

`max_num_buckets` means the maximum number of buckets that can be used, by default it is 128.

For example:
```sql
select histogram(c_id) from histagg;
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ histogram(c_id) │
│ Nullable(String) │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ [{"lower":"1","upper":"1","ndv":1,"count":6,"pre_sum":0},{"lower":"2","upper":"2","ndv":1,"count":6,"pre_sum":6}] │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
-- The following two forms are equivalent:
HISTOGRAM(<max_num_buckets>)(<expr>)
HISTOGRAM(<expr> [, <max_num_buckets>])
```
:::

## Arguments

| Arguments | Description |
|-------------------|--------------------------------------------------------------------------------------------|
| `<expr>` | The data type of `<expr>` should be sortable. |
| `max_num_buckets` | Optional constant positive integer, the maximum number of buckets that can be used. |
| Parameter | Description |
|-------------------|-------------------------------------------------------------------------------------|
| `expr` | The data type of `expr` should be sortable. |
| `max_num_buckets` | Optional positive integer specifying the maximum number of buckets. Default is 128. |

## Return Type

the Nullable String type
Returns either an empty string or a JSON object with the following structure:

## Example
- **buckets**: List of buckets with detailed information:
- **lower**: Lower bound of the bucket.
- **upper**: Upper bound of the bucket.
- **count**: Number of elements in the bucket.
- **pre_sum**: Cumulative count of elements up to the current bucket.
- **ndv**: Number of distinct values in the bucket.

**Create a Table and Insert Sample Data**
## Examples

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:

```sql
CREATE TABLE histagg (
Expand All @@ -58,24 +52,17 @@ INSERT INTO histagg VALUES
(2, 21, 22, 23),
(2, 31, 32, 33),
(2, 10, 20, 30);
```

**Query Demo 1**
```sql
SELECT HISTOGRAM(c_int) FROM histagg;
```

**Result**
```sql
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ histogram(c_int) │
│ Nullable(String) │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ [{"lower":"13","upper":"13","ndv":1,"count":1,"pre_sum":0},{"lower":"23","upper":"23","ndv":1,"count":1,"pre_sum":1},{"lower":"30","upper":"30","ndv":1,"count":2,"pre_sum":2},{"lower":"33","upper":"33","ndv":1,"count":2,"pre_sum":4}] │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

Query result description:
The result is returned as a JSON array:

```json
[
Expand Down Expand Up @@ -110,11 +97,37 @@ Query result description:
]
```

Fields description:
This example shows how `HISTOGRAM(2)` groups c_int values into two buckets:

- buckets:All buckets
- lower:Upper bound of the bucket
- upper:Lower bound of the bucket
- count:The number of elements contained in the bucket
- pre_sum:The total number of elements in the front bucket
- ndv:The number of distinct values in the bucket
```sql
SELECT HISTOGRAM(2)(c_int) FROM histagg;
-- Or
SELECT HISTOGRAM(c_int, 2) FROM histagg;

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ histogram(2)(c_int) │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ [{"lower":"13","upper":"30","ndv":3,"count":4,"pre_sum":0},{"lower":"33","upper":"33","ndv":1,"count":2,"pre_sum":4}] │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

The result is returned as a JSON array:

```json
[
{
"lower": "13",
"upper": "30",
"ndv": 3,
"count": 4,
"pre_sum": 0
},
{
"lower": "33",
"upper": "33",
"ndv": 1,
"count": 2,
"pre_sum": 4
}
]
```
10 changes: 8 additions & 2 deletions src/components/DocsOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const colLayout3 = { xl: 8, xxl: 8, lg: 8, md: 8, sm: 12, xs: 24 };
const DocsOverview: FC = (): ReactElement => {
const {
siteConfig: {
customFields: { homeLink },
customFields: { homeLink, isChina },
},
} = useDocusaurusContext();
return (
Expand Down Expand Up @@ -163,7 +163,13 @@ const DocsOverview: FC = (): ReactElement => {
<div>{$t("Topics you might find useful:")}</div>
<ul>
<li>
<Link to={"/guides/deploy/deploy/download"}>
<Link
to={
isChina
? "/guides/overview/editions/dce/download"
: "/guides/deploy/deploy/download"
}
>
{$t("Downloading Databend")}
</Link>
</li>
Expand Down

0 comments on commit a9039ec

Please sign in to comment.