This is an automated email from the ASF dual-hosted git repository. kassiez pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new f3e8b2cd277 Fix hll function (#1913) f3e8b2cd277 is described below commit f3e8b2cd2773b445c359d98705465b757170b3d6 Author: echo-dundun <50286010+echo-...@users.noreply.github.com> AuthorDate: Fri Jan 24 15:03:22 2025 +0800 Fix hll function (#1913) ## Versions - [x] dev - [x] 3.0 - [x] 2.1 - [x] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --- .../hll-functions/hll-cardinality.md | 34 +++++++---- .../scalar-functions/hll-functions/hll-empty.md | 28 +++++---- .../hll-functions/hll-from-base64.md | 54 +++++++++++------ .../scalar-functions/hll-functions/hll-hash.md | 29 ++++++---- .../hll-functions/hll-to-base64.md | 64 ++++++++++++++------- .../hll-functions/hll-cardinality.md | 28 ++++++--- .../scalar-functions/hll-functions/hll-empty.md | 22 ++++--- .../hll-functions/hll-from-base64.md | 67 +++++++++++----------- .../scalar-functions/hll-functions/hll-hash.md | 31 +++++++--- .../hll-functions/hll-to-base64.md | 60 +++++++++++++------ .../sql-functions/hll-functions/hll-empty.md | 22 ++++--- .../sql-functions/hll-functions/hll-hash.md | 31 +++++++--- .../sql-functions/hll-functions/hll-cardinality.md | 28 ++++++--- .../sql-functions/hll-functions/hll-empty.md | 22 ++++--- .../sql-functions/hll-functions/hll-hash.md | 31 +++++++--- .../hll-functions/hll-cardinality.md | 28 ++++++--- .../scalar-functions/hll-functions/hll-empty.md | 22 ++++--- .../hll-functions/hll-from-base64.md | 67 +++++++++++----------- .../scalar-functions/hll-functions/hll-hash.md | 31 +++++++--- .../hll-functions/hll-to-base64.md | 60 +++++++++++++------ .../hll-functions/hll-cardinality.md | 28 ++++++--- .../scalar-functions/hll-functions/hll-empty.md | 22 ++++--- .../hll-functions/hll-from-base64.md | 67 +++++++++++----------- .../scalar-functions/hll-functions/hll-hash.md | 31 +++++++--- .../hll-functions/hll-to-base64.md | 60 +++++++++++++------ .../sql-functions/hll-functions/hll-empty.md | 28 +++++---- .../sql-functions/hll-functions/hll-hash.md | 29 ++++++---- .../sql-functions/hll-functions/hll-cardinality.md | 34 +++++++---- .../sql-functions/hll-functions/hll-empty.md | 28 +++++---- .../sql-functions/hll-functions/hll-hash.md | 29 ++++++---- .../hll-functions/hll-cardinality.md | 34 +++++++---- .../scalar-functions/hll-functions/hll-empty.md | 28 +++++---- .../hll-functions/hll-from-base64.md | 54 +++++++++++------ .../scalar-functions/hll-functions/hll-hash.md | 29 ++++++---- .../hll-functions/hll-to-base64.md | 66 ++++++++++++++------- .../hll-functions/hll-cardinality.md | 34 +++++++---- .../scalar-functions/hll-functions/hll-empty.md | 28 +++++---- .../hll-functions/hll-from-base64.md | 54 +++++++++++------ .../scalar-functions/hll-functions/hll-hash.md | 29 ++++++---- .../hll-functions/hll-to-base64.md | 66 ++++++++++++++------- 40 files changed, 1032 insertions(+), 505 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md index db1b7437ca3..f45b54272cd 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md +++ b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md @@ -24,22 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_CARDINALITY -### description -#### Syntax +## Description -`HLL_CARDINALITY(hll)` +`HLL_CARDINALITY` calculates the cardinality of a HyperLogLog (HLL) type value. It is an approximate counting algorithm suitable for estimating the number of distinct elements in large datasets. -HLL_CARDINALITY is used to calculate the cardinality of a single HLL type value. +## Syntax -### example +```sql +HLL_CARDINALITY(<hll>) ``` -MySQL > select HLL_CARDINALITY(uv_set) from test_uv; + +## Parameters + +| Parameter | Description | +| ---------- | -------------------------------------------------------- | +| `<hll>` | The HLL type value representing the dataset whose cardinality needs to be estimated. | + +## Return Value + +Returns the estimated cardinality of the HLL type value, representing the number of distinct elements in the dataset. + +## Example + +```sql +select HLL_CARDINALITY(uv_set) from test_uv; +``` + +```text +---------------------------+ | hll_cardinality(`uv_set`) | +---------------------------+ | 3 | +---------------------------+ -``` -### keywords -HLL,HLL_CARDINALITY +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md index 776a7c3722e..75cc2b34805 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md +++ b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY -### description -#### Syntax +## Description -`HLL_EMPTY(value)` +`HLL_EMPTY` returns an empty HLL (HyperLogLog) value, representing a data set with no elements. -HLL_EMPTY returns a null value of type hll. +## Syntax -### example +```sql +HLL_EMPTY() ``` -MySQL > select hll_cardinality(hll_empty()); + +## Return Value + +Returns an empty HLL type value, representing a data set with no elements. + +## Example + +```sql +select hll_cardinality(hll_empty()); +``` + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md index c0efeb46449..8a25e148373 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md +++ b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md @@ -22,50 +22,68 @@ specific language governing permissions and limitations under the License. --> -## hll_from_base64 +## Description -### description -#### Syntax +Converts a base64-encoded string (usually the result of the `HLL_TO_BASE64` function) into an HLL. If the input string is invalid or NULL, the function returns NULL. -`HLL HLL_FROM_BASE64(VARCHAR input)` +## Syntax -Convert a base64 string(result of function `hll_to_base64`) into a hll. If input string is invalid, return NULL. +```sql +HLL_FROM_BASE64(<input>) +``` + +## Parameters -### example +| Parameter | Description | +| --------- | --------------------------------------------------------------------------- | +| `<input>` | A base64-encoded string, typically generated by the `HLL_TO_BASE64` function. If the input string is invalid or NULL, the function returns NULL. | +## Examples + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; ``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; + +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +``` + +```text +---------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))) | +---------------------------------------------------------------+ | 1 | +---------------------------------------------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +``` + +```text +-----------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))) | +-----------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------+ -1 row in set (0.02 sec) -``` - -### keywords -HLL_FROM_BASE64, HLL +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md index b174e6236e8..d2df2cd4016 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md +++ b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md @@ -24,23 +24,32 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH -### description -#### Syntax +## Description -`HLL_HASH(value)` +Converts a given value to the HLL (HyperLogLog) type. This function is typically used during data loading to create an HLL from raw data. -HLL_HASH converts a value to hll type. -Typically used when loading data. +## Syntax -### example +```sql +HLL_HASH(<value>) ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +## Parameters + +| Parameter | Description | +|-----------|---------------------------------------------------------------| +| `<value>` | The value to be converted to HLL type. This can be a string, number, or any data type. | + +## Examples + +```sql +SELECT HLL_CARDINALITY(HLL_HASH('abc')); +``` + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ ``` -### keywords -HLL,HLL_HASH diff --git a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md index 6da0051d84c..5b8d885370d 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md +++ b/docs/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md @@ -1,8 +1,10 @@ --- + { "title": "HLL_TO_BASE64", "language": "en" } + --- <!-- @@ -22,58 +24,80 @@ specific language governing permissions and limitations under the License. --> -## hll_to_base64 +## Description + +Converts an input HLL to a base64-encoded string. If the input is `<null>`, the function returns `<null>`. -### description -#### Syntax +## Syntax + +```sql +HLL_TO_BASE64(<hll_input>) +``` -`VARCHAR HLL_TO_BASE64(HLL input)` +## Parameters -Convert an input hll to a base64 string. If input is NULL, return NULL. +| Parameter | Description | +| ------------ | ---------------------------------------------------- | +| `<hll_input>` | The HyperLogLog (HLL) data to be converted to a base64-encoded string. If the input is `<null>`, the function returns `<null>`. | -### example +## Examples +```sql +select hll_to_base64(NULL); ``` -mysql> select hll_to_base64(NULL); + +```text +---------------------+ | hll_to_base64(NULL) | +---------------------+ | NULL | +---------------------+ -1 row in set (0.00 sec) +``` -mysql> select hll_to_base64(hll_empty()); +```sql +select hll_to_base64(hll_empty()); +``` + +```text +----------------------------+ | hll_to_base64(hll_empty()) | +----------------------------+ | AA== | +----------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_to_base64(hll_hash('abc')); +```sql +select hll_to_base64(hll_hash('abc')); +``` + +```text +--------------------------------+ | hll_to_base64(hll_hash('abc')) | +--------------------------------+ | AQEC5XSzrpDsdw== | +--------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) -``` - -### keywords -HLL_TO_BASE64, HLL +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md index 76390c4f53c..fe065be3191 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md @@ -24,22 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_CARDINALITY ## 描述 + +`HLL_CARDINALITY` 用于计算 HLL(HyperLogLog)类型值的基数。HLL 是一种近似计数的算法,适用于大规模数据集的基数估算。 + ## 语法 -`HLL_CARDINALITY(hll)` +```sql +HLL_CARDINALITY(<hll>) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | -------------------------------------- | +| `<hll>` | HLL 类型的值,表示需要计算基数的数据集合。 | -HLL_CARDINALITY 用于计算 HLL 类型值的基数。 +## 返回值 + +返回 HLL 类型值的基数,即数据集合中不重复元素的估算数。 ## 举例 + +```sql +select HLL_CARDINALITY(uv_set) from test_uv; ``` -MySQL > select HLL_CARDINALITY(uv_set) from test_uv; + +```text +---------------------------+ | hll_cardinality(`uv_set`) | +---------------------------+ | 3 | +---------------------------+ -``` -### keywords -HLL,HLL_CARDINALITY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md index 340d4ebe2de..760b736a248 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY ## 描述 + +`HLL_EMPTY` 用于返回一个 HLL(HyperLogLog)类型的空值,表示一个没有任何元素的数据集合。 + ## 语法 -`HLL_EMPTY(value)` +```sql +HLL_EMPTY() +``` + +## 返回值 -HLL_EMPTY 返回一个 hll 类型的空值。 +返回一个 HLL 类型的空值,表示一个没有任何元素的数据集合。 ## 举例 + +```sql +select hll_cardinality(hll_empty()); ``` -MySQL > select hll_cardinality(hll_empty()); + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md index 3a7e2a7bb9c..aef2b28fbfb 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md @@ -22,65 +22,68 @@ specific language governing permissions and limitations under the License. --> -## hll_from_base64 - ## 描述 + +将一个 base64 编码的字符串(通常由 `HLL_TO_BASE64` 函数生成)转换为 HLL 类型。如果输入字符串不合法或为 NULL,则返回 NULL。 + ## 语法 -`HLL HLL_FROM_BASE64(VARCHAR input)` +```sql +HLL_FROM_BASE64(<input>) +``` + +## 参数 -将一个base64字符串(`hll_to_base64`函数的结果)转化为一个HLL。当输入字符串不合法时,返回NULL。 +| 参数 | 说明 | +| -------- | ------------------------------------------------------------------------ | +| `<input>` | base64 编码的字符串,通常由 `HLL_TO_BASE64` 函数生成。如果字符串不合法,则返回 NULL。 | -## 举例 +## 示例 -#### 查询示例 +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; ``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; + +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +```text +---------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))) | +---------------------------------------------------------------+ | 1 | +---------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +```text +-----------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))) | +-----------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------+ -1 row in set (0.02 sec) -``` - -#### 数据导入示例: -``` -前置条件: -1. 在 Hive 中已经创建好一个名为 hive_test.hive_hll_table 的 Hive 表(格式为 textfile ,字段为:`k1` int, `k2` String, `k3` String, `uuid` binary),并且已经基于普通表使用 to_hll 的UDF函数往该表插入数据。 - -2. 在 Doris 中创建名为 hive 的 Catalog 用来连接。 - -3. 创建好 Doris 内表,名为 doris_hll_table,字段有:`k1` int, `k2` varchar(10), `k3` varchar(10), `uuid` HLL HLL_UNION。 - -那么,此时可以使用 hll_from_base64 函数从 Hive 插入数据到 Doris 中: -insert into doris_hll_table select k1, k2, k3, hll_from_base64(uuid) from hive.hive_test.hive_hll_table; -``` -更多导入细节可以参考:[Hive HLL UDF](../../../ecosystem/hive-hll-udf.md) - -### keywords -HLL_FROM_BASE64,HLL +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md index b7564691945..4a7337ee415 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md @@ -24,22 +24,39 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH ## 描述 + +将一个值转换为 HLL(HyperLogLog)类型。该函数通常用于数据加载时,将普通类型的值转换为 HLL 类型,常用于处理大数据集的去重和计数操作。 + +特殊情况: +- 如果输入值为 NULL,则返回 NULL。 + ## 语法 -`HLL_HASH(value)` +```sql +HLL_HASH(<value>) +``` + +## 参数 -HLL_HASH 将一个值转换为 hll 类型。通常用于导入数据时,将普通类型的值导入到 hll 列中。 +| 参数 | 说明 | +| -------- | ------------------------------------------------------ | +| `<value>` | 需要转换为 HLL 类型的值。可以是字符串、数字或任意数据类型。 | + +## 返回值 + +返回一个 HLL 类型的值。返回结果类型为 HLL。 ## 举例 + +```sql +select HLL_CARDINALITY(HLL_HASH('abc')); ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ -``` -### keywords -HLL,HLL_HASH +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md index dbcb1254c03..a8d786c0268 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md @@ -22,58 +22,80 @@ specific language governing permissions and limitations under the License. --> -## hll_to_base64 - ## 描述 + +将一个 HLL 类型转换为一个 base64 编码的字符串。如果输入为 NULL,则返回 NULL。 + ## 语法 -`VARCHAR HLL_TO_BASE64(HLL input)` +```sql +HLL_TO_BASE64(<hll_input>) +``` + +## 参数 -将一个hll转化成一个base64字符串。输入是NULL的话返回NULL。 +| 参数 | 说明 | +| ----------- | ---------------------------------------- | +| `<hll_input>` | HLL 类型数据,如果输入为 NULL,则返回 NULL。 | -## 举例 +## 示例 +```sql +select hll_to_base64(NULL); ``` -mysql> select hll_to_base64(NULL); + +```text +---------------------+ | hll_to_base64(NULL) | +---------------------+ | NULL | +---------------------+ -1 row in set (0.00 sec) +``` -mysql> select hll_to_base64(hll_empty()); +```sql +select hll_to_base64(hll_empty()); +``` + +```text +----------------------------+ | hll_to_base64(hll_empty()) | +----------------------------+ | AA== | +----------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_to_base64(hll_hash('abc')); +```sql +select hll_to_base64(hll_hash('abc')); +``` + +```text +--------------------------------+ | hll_to_base64(hll_hash('abc')) | +--------------------------------+ | AQEC5XSzrpDsdw== | +--------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) -``` - -### keywords -HLL_TO_BASE64, HLL +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md index 340d4ebe2de..760b736a248 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY ## 描述 + +`HLL_EMPTY` 用于返回一个 HLL(HyperLogLog)类型的空值,表示一个没有任何元素的数据集合。 + ## 语法 -`HLL_EMPTY(value)` +```sql +HLL_EMPTY() +``` + +## 返回值 -HLL_EMPTY 返回一个 hll 类型的空值。 +返回一个 HLL 类型的空值,表示一个没有任何元素的数据集合。 ## 举例 + +```sql +select hll_cardinality(hll_empty()); ``` -MySQL > select hll_cardinality(hll_empty()); + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md index b7564691945..4a7337ee415 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md @@ -24,22 +24,39 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH ## 描述 + +将一个值转换为 HLL(HyperLogLog)类型。该函数通常用于数据加载时,将普通类型的值转换为 HLL 类型,常用于处理大数据集的去重和计数操作。 + +特殊情况: +- 如果输入值为 NULL,则返回 NULL。 + ## 语法 -`HLL_HASH(value)` +```sql +HLL_HASH(<value>) +``` + +## 参数 -HLL_HASH 将一个值转换为 hll 类型。通常用于导入数据时,将普通类型的值导入到 hll 列中。 +| 参数 | 说明 | +| -------- | ------------------------------------------------------ | +| `<value>` | 需要转换为 HLL 类型的值。可以是字符串、数字或任意数据类型。 | + +## 返回值 + +返回一个 HLL 类型的值。返回结果类型为 HLL。 ## 举例 + +```sql +select HLL_CARDINALITY(HLL_HASH('abc')); ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ -``` -### keywords -HLL,HLL_HASH +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-cardinality.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-cardinality.md index 76390c4f53c..fe065be3191 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-cardinality.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-cardinality.md @@ -24,22 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_CARDINALITY ## 描述 + +`HLL_CARDINALITY` 用于计算 HLL(HyperLogLog)类型值的基数。HLL 是一种近似计数的算法,适用于大规模数据集的基数估算。 + ## 语法 -`HLL_CARDINALITY(hll)` +```sql +HLL_CARDINALITY(<hll>) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | -------------------------------------- | +| `<hll>` | HLL 类型的值,表示需要计算基数的数据集合。 | -HLL_CARDINALITY 用于计算 HLL 类型值的基数。 +## 返回值 + +返回 HLL 类型值的基数,即数据集合中不重复元素的估算数。 ## 举例 + +```sql +select HLL_CARDINALITY(uv_set) from test_uv; ``` -MySQL > select HLL_CARDINALITY(uv_set) from test_uv; + +```text +---------------------------+ | hll_cardinality(`uv_set`) | +---------------------------+ | 3 | +---------------------------+ -``` -### keywords -HLL,HLL_CARDINALITY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-empty.md index 340d4ebe2de..760b736a248 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-empty.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY ## 描述 + +`HLL_EMPTY` 用于返回一个 HLL(HyperLogLog)类型的空值,表示一个没有任何元素的数据集合。 + ## 语法 -`HLL_EMPTY(value)` +```sql +HLL_EMPTY() +``` + +## 返回值 -HLL_EMPTY 返回一个 hll 类型的空值。 +返回一个 HLL 类型的空值,表示一个没有任何元素的数据集合。 ## 举例 + +```sql +select hll_cardinality(hll_empty()); ``` -MySQL > select hll_cardinality(hll_empty()); + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-hash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-hash.md index b7564691945..4a7337ee415 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-hash.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-hash.md @@ -24,22 +24,39 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH ## 描述 + +将一个值转换为 HLL(HyperLogLog)类型。该函数通常用于数据加载时,将普通类型的值转换为 HLL 类型,常用于处理大数据集的去重和计数操作。 + +特殊情况: +- 如果输入值为 NULL,则返回 NULL。 + ## 语法 -`HLL_HASH(value)` +```sql +HLL_HASH(<value>) +``` + +## 参数 -HLL_HASH 将一个值转换为 hll 类型。通常用于导入数据时,将普通类型的值导入到 hll 列中。 +| 参数 | 说明 | +| -------- | ------------------------------------------------------ | +| `<value>` | 需要转换为 HLL 类型的值。可以是字符串、数字或任意数据类型。 | + +## 返回值 + +返回一个 HLL 类型的值。返回结果类型为 HLL。 ## 举例 + +```sql +select HLL_CARDINALITY(HLL_HASH('abc')); ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ -``` -### keywords -HLL,HLL_HASH +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md index 76390c4f53c..fe065be3191 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md @@ -24,22 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_CARDINALITY ## 描述 + +`HLL_CARDINALITY` 用于计算 HLL(HyperLogLog)类型值的基数。HLL 是一种近似计数的算法,适用于大规模数据集的基数估算。 + ## 语法 -`HLL_CARDINALITY(hll)` +```sql +HLL_CARDINALITY(<hll>) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | -------------------------------------- | +| `<hll>` | HLL 类型的值,表示需要计算基数的数据集合。 | -HLL_CARDINALITY 用于计算 HLL 类型值的基数。 +## 返回值 + +返回 HLL 类型值的基数,即数据集合中不重复元素的估算数。 ## 举例 + +```sql +select HLL_CARDINALITY(uv_set) from test_uv; ``` -MySQL > select HLL_CARDINALITY(uv_set) from test_uv; + +```text +---------------------------+ | hll_cardinality(`uv_set`) | +---------------------------+ | 3 | +---------------------------+ -``` -### keywords -HLL,HLL_CARDINALITY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md index 340d4ebe2de..760b736a248 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY ## 描述 + +`HLL_EMPTY` 用于返回一个 HLL(HyperLogLog)类型的空值,表示一个没有任何元素的数据集合。 + ## 语法 -`HLL_EMPTY(value)` +```sql +HLL_EMPTY() +``` + +## 返回值 -HLL_EMPTY 返回一个 hll 类型的空值。 +返回一个 HLL 类型的空值,表示一个没有任何元素的数据集合。 ## 举例 + +```sql +select hll_cardinality(hll_empty()); ``` -MySQL > select hll_cardinality(hll_empty()); + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md index 3a7e2a7bb9c..aef2b28fbfb 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md @@ -22,65 +22,68 @@ specific language governing permissions and limitations under the License. --> -## hll_from_base64 - ## 描述 + +将一个 base64 编码的字符串(通常由 `HLL_TO_BASE64` 函数生成)转换为 HLL 类型。如果输入字符串不合法或为 NULL,则返回 NULL。 + ## 语法 -`HLL HLL_FROM_BASE64(VARCHAR input)` +```sql +HLL_FROM_BASE64(<input>) +``` + +## 参数 -将一个base64字符串(`hll_to_base64`函数的结果)转化为一个HLL。当输入字符串不合法时,返回NULL。 +| 参数 | 说明 | +| -------- | ------------------------------------------------------------------------ | +| `<input>` | base64 编码的字符串,通常由 `HLL_TO_BASE64` 函数生成。如果字符串不合法,则返回 NULL。 | -## 举例 +## 示例 -#### 查询示例 +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; ``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; + +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +```text +---------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))) | +---------------------------------------------------------------+ | 1 | +---------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +```text +-----------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))) | +-----------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------+ -1 row in set (0.02 sec) -``` - -#### 数据导入示例: -``` -前置条件: -1. 在 Hive 中已经创建好一个名为 hive_test.hive_hll_table 的 Hive 表(格式为 textfile ,字段为:`k1` int, `k2` String, `k3` String, `uuid` binary),并且已经基于普通表使用 to_hll 的UDF函数往该表插入数据。 - -2. 在 Doris 中创建名为 hive 的 Catalog 用来连接。 - -3. 创建好 Doris 内表,名为 doris_hll_table,字段有:`k1` int, `k2` varchar(10), `k3` varchar(10), `uuid` HLL HLL_UNION。 - -那么,此时可以使用 hll_from_base64 函数从 Hive 插入数据到 Doris 中: -insert into doris_hll_table select k1, k2, k3, hll_from_base64(uuid) from hive.hive_test.hive_hll_table; -``` -更多导入细节可以参考:[Hive HLL UDF](../../../ecosystem/hive-hll-udf.md) - -### keywords -HLL_FROM_BASE64,HLL +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md index b7564691945..4a7337ee415 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md @@ -24,22 +24,39 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH ## 描述 + +将一个值转换为 HLL(HyperLogLog)类型。该函数通常用于数据加载时,将普通类型的值转换为 HLL 类型,常用于处理大数据集的去重和计数操作。 + +特殊情况: +- 如果输入值为 NULL,则返回 NULL。 + ## 语法 -`HLL_HASH(value)` +```sql +HLL_HASH(<value>) +``` + +## 参数 -HLL_HASH 将一个值转换为 hll 类型。通常用于导入数据时,将普通类型的值导入到 hll 列中。 +| 参数 | 说明 | +| -------- | ------------------------------------------------------ | +| `<value>` | 需要转换为 HLL 类型的值。可以是字符串、数字或任意数据类型。 | + +## 返回值 + +返回一个 HLL 类型的值。返回结果类型为 HLL。 ## 举例 + +```sql +select HLL_CARDINALITY(HLL_HASH('abc')); ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ -``` -### keywords -HLL,HLL_HASH +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md index dbcb1254c03..a8d786c0268 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md @@ -22,58 +22,80 @@ specific language governing permissions and limitations under the License. --> -## hll_to_base64 - ## 描述 + +将一个 HLL 类型转换为一个 base64 编码的字符串。如果输入为 NULL,则返回 NULL。 + ## 语法 -`VARCHAR HLL_TO_BASE64(HLL input)` +```sql +HLL_TO_BASE64(<hll_input>) +``` + +## 参数 -将一个hll转化成一个base64字符串。输入是NULL的话返回NULL。 +| 参数 | 说明 | +| ----------- | ---------------------------------------- | +| `<hll_input>` | HLL 类型数据,如果输入为 NULL,则返回 NULL。 | -## 举例 +## 示例 +```sql +select hll_to_base64(NULL); ``` -mysql> select hll_to_base64(NULL); + +```text +---------------------+ | hll_to_base64(NULL) | +---------------------+ | NULL | +---------------------+ -1 row in set (0.00 sec) +``` -mysql> select hll_to_base64(hll_empty()); +```sql +select hll_to_base64(hll_empty()); +``` + +```text +----------------------------+ | hll_to_base64(hll_empty()) | +----------------------------+ | AA== | +----------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_to_base64(hll_hash('abc')); +```sql +select hll_to_base64(hll_hash('abc')); +``` + +```text +--------------------------------+ | hll_to_base64(hll_hash('abc')) | +--------------------------------+ | AQEC5XSzrpDsdw== | +--------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) -``` - -### keywords -HLL_TO_BASE64, HLL +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md index 76390c4f53c..fe065be3191 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md @@ -24,22 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_CARDINALITY ## 描述 + +`HLL_CARDINALITY` 用于计算 HLL(HyperLogLog)类型值的基数。HLL 是一种近似计数的算法,适用于大规模数据集的基数估算。 + ## 语法 -`HLL_CARDINALITY(hll)` +```sql +HLL_CARDINALITY(<hll>) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | -------------------------------------- | +| `<hll>` | HLL 类型的值,表示需要计算基数的数据集合。 | -HLL_CARDINALITY 用于计算 HLL 类型值的基数。 +## 返回值 + +返回 HLL 类型值的基数,即数据集合中不重复元素的估算数。 ## 举例 + +```sql +select HLL_CARDINALITY(uv_set) from test_uv; ``` -MySQL > select HLL_CARDINALITY(uv_set) from test_uv; + +```text +---------------------------+ | hll_cardinality(`uv_set`) | +---------------------------+ | 3 | +---------------------------+ -``` -### keywords -HLL,HLL_CARDINALITY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md index 340d4ebe2de..760b736a248 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY ## 描述 + +`HLL_EMPTY` 用于返回一个 HLL(HyperLogLog)类型的空值,表示一个没有任何元素的数据集合。 + ## 语法 -`HLL_EMPTY(value)` +```sql +HLL_EMPTY() +``` + +## 返回值 -HLL_EMPTY 返回一个 hll 类型的空值。 +返回一个 HLL 类型的空值,表示一个没有任何元素的数据集合。 ## 举例 + +```sql +select hll_cardinality(hll_empty()); ``` -MySQL > select hll_cardinality(hll_empty()); + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md index 3a7e2a7bb9c..aef2b28fbfb 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md @@ -22,65 +22,68 @@ specific language governing permissions and limitations under the License. --> -## hll_from_base64 - ## 描述 + +将一个 base64 编码的字符串(通常由 `HLL_TO_BASE64` 函数生成)转换为 HLL 类型。如果输入字符串不合法或为 NULL,则返回 NULL。 + ## 语法 -`HLL HLL_FROM_BASE64(VARCHAR input)` +```sql +HLL_FROM_BASE64(<input>) +``` + +## 参数 -将一个base64字符串(`hll_to_base64`函数的结果)转化为一个HLL。当输入字符串不合法时,返回NULL。 +| 参数 | 说明 | +| -------- | ------------------------------------------------------------------------ | +| `<input>` | base64 编码的字符串,通常由 `HLL_TO_BASE64` 函数生成。如果字符串不合法,则返回 NULL。 | -## 举例 +## 示例 -#### 查询示例 +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; ``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; + +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +```text +---------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))) | +---------------------------------------------------------------+ | 1 | +---------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +```text +-----------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))) | +-----------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------+ -1 row in set (0.02 sec) -``` - -#### 数据导入示例: -``` -前置条件: -1. 在 Hive 中已经创建好一个名为 hive_test.hive_hll_table 的 Hive 表(格式为 textfile ,字段为:`k1` int, `k2` String, `k3` String, `uuid` binary),并且已经基于普通表使用 to_hll 的UDF函数往该表插入数据。 - -2. 在 Doris 中创建名为 hive 的 Catalog 用来连接。 - -3. 创建好 Doris 内表,名为 doris_hll_table,字段有:`k1` int, `k2` varchar(10), `k3` varchar(10), `uuid` HLL HLL_UNION。 - -那么,此时可以使用 hll_from_base64 函数从 Hive 插入数据到 Doris 中: -insert into doris_hll_table select k1, k2, k3, hll_from_base64(uuid) from hive.hive_test.hive_hll_table; -``` -更多导入细节可以参考:[Hive HLL UDF](../../../ecosystem/hive-hll-udf.md) - -### keywords -HLL_FROM_BASE64,HLL +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md index b7564691945..4a7337ee415 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md @@ -24,22 +24,39 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH ## 描述 + +将一个值转换为 HLL(HyperLogLog)类型。该函数通常用于数据加载时,将普通类型的值转换为 HLL 类型,常用于处理大数据集的去重和计数操作。 + +特殊情况: +- 如果输入值为 NULL,则返回 NULL。 + ## 语法 -`HLL_HASH(value)` +```sql +HLL_HASH(<value>) +``` + +## 参数 -HLL_HASH 将一个值转换为 hll 类型。通常用于导入数据时,将普通类型的值导入到 hll 列中。 +| 参数 | 说明 | +| -------- | ------------------------------------------------------ | +| `<value>` | 需要转换为 HLL 类型的值。可以是字符串、数字或任意数据类型。 | + +## 返回值 + +返回一个 HLL 类型的值。返回结果类型为 HLL。 ## 举例 + +```sql +select HLL_CARDINALITY(HLL_HASH('abc')); ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ -``` -### keywords -HLL,HLL_HASH +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md index dbcb1254c03..a8d786c0268 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md @@ -22,58 +22,80 @@ specific language governing permissions and limitations under the License. --> -## hll_to_base64 - ## 描述 + +将一个 HLL 类型转换为一个 base64 编码的字符串。如果输入为 NULL,则返回 NULL。 + ## 语法 -`VARCHAR HLL_TO_BASE64(HLL input)` +```sql +HLL_TO_BASE64(<hll_input>) +``` + +## 参数 -将一个hll转化成一个base64字符串。输入是NULL的话返回NULL。 +| 参数 | 说明 | +| ----------- | ---------------------------------------- | +| `<hll_input>` | HLL 类型数据,如果输入为 NULL,则返回 NULL。 | -## 举例 +## 示例 +```sql +select hll_to_base64(NULL); ``` -mysql> select hll_to_base64(NULL); + +```text +---------------------+ | hll_to_base64(NULL) | +---------------------+ | NULL | +---------------------+ -1 row in set (0.00 sec) +``` -mysql> select hll_to_base64(hll_empty()); +```sql +select hll_to_base64(hll_empty()); +``` + +```text +----------------------------+ | hll_to_base64(hll_empty()) | +----------------------------+ | AA== | +----------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_to_base64(hll_hash('abc')); +```sql +select hll_to_base64(hll_hash('abc')); +``` + +```text +--------------------------------+ | hll_to_base64(hll_hash('abc')) | +--------------------------------+ | AQEC5XSzrpDsdw== | +--------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) -``` - -### keywords -HLL_TO_BASE64, HLL +``` \ No newline at end of file diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md b/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md index 776a7c3722e..75cc2b34805 100644 --- a/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md +++ b/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY -### description -#### Syntax +## Description -`HLL_EMPTY(value)` +`HLL_EMPTY` returns an empty HLL (HyperLogLog) value, representing a data set with no elements. -HLL_EMPTY returns a null value of type hll. +## Syntax -### example +```sql +HLL_EMPTY() ``` -MySQL > select hll_cardinality(hll_empty()); + +## Return Value + +Returns an empty HLL type value, representing a data set with no elements. + +## Example + +```sql +select hll_cardinality(hll_empty()); +``` + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md b/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md index b174e6236e8..d2df2cd4016 100644 --- a/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md +++ b/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md @@ -24,23 +24,32 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH -### description -#### Syntax +## Description -`HLL_HASH(value)` +Converts a given value to the HLL (HyperLogLog) type. This function is typically used during data loading to create an HLL from raw data. -HLL_HASH converts a value to hll type. -Typically used when loading data. +## Syntax -### example +```sql +HLL_HASH(<value>) ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +## Parameters + +| Parameter | Description | +|-----------|---------------------------------------------------------------| +| `<value>` | The value to be converted to HLL type. This can be a string, number, or any data type. | + +## Examples + +```sql +SELECT HLL_CARDINALITY(HLL_HASH('abc')); +``` + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ ``` -### keywords -HLL,HLL_HASH diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-cardinality.md b/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-cardinality.md index db1b7437ca3..f45b54272cd 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-cardinality.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-cardinality.md @@ -24,22 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_CARDINALITY -### description -#### Syntax +## Description -`HLL_CARDINALITY(hll)` +`HLL_CARDINALITY` calculates the cardinality of a HyperLogLog (HLL) type value. It is an approximate counting algorithm suitable for estimating the number of distinct elements in large datasets. -HLL_CARDINALITY is used to calculate the cardinality of a single HLL type value. +## Syntax -### example +```sql +HLL_CARDINALITY(<hll>) ``` -MySQL > select HLL_CARDINALITY(uv_set) from test_uv; + +## Parameters + +| Parameter | Description | +| ---------- | -------------------------------------------------------- | +| `<hll>` | The HLL type value representing the dataset whose cardinality needs to be estimated. | + +## Return Value + +Returns the estimated cardinality of the HLL type value, representing the number of distinct elements in the dataset. + +## Example + +```sql +select HLL_CARDINALITY(uv_set) from test_uv; +``` + +```text +---------------------------+ | hll_cardinality(`uv_set`) | +---------------------------+ | 3 | +---------------------------+ -``` -### keywords -HLL,HLL_CARDINALITY +``` \ No newline at end of file diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-empty.md b/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-empty.md index 776a7c3722e..75cc2b34805 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-empty.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY -### description -#### Syntax +## Description -`HLL_EMPTY(value)` +`HLL_EMPTY` returns an empty HLL (HyperLogLog) value, representing a data set with no elements. -HLL_EMPTY returns a null value of type hll. +## Syntax -### example +```sql +HLL_EMPTY() ``` -MySQL > select hll_cardinality(hll_empty()); + +## Return Value + +Returns an empty HLL type value, representing a data set with no elements. + +## Example + +```sql +select hll_cardinality(hll_empty()); +``` + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-hash.md b/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-hash.md index b174e6236e8..d2df2cd4016 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-hash.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/hll-functions/hll-hash.md @@ -24,23 +24,32 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH -### description -#### Syntax +## Description -`HLL_HASH(value)` +Converts a given value to the HLL (HyperLogLog) type. This function is typically used during data loading to create an HLL from raw data. -HLL_HASH converts a value to hll type. -Typically used when loading data. +## Syntax -### example +```sql +HLL_HASH(<value>) ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +## Parameters + +| Parameter | Description | +|-----------|---------------------------------------------------------------| +| `<value>` | The value to be converted to HLL type. This can be a string, number, or any data type. | + +## Examples + +```sql +SELECT HLL_CARDINALITY(HLL_HASH('abc')); +``` + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ ``` -### keywords -HLL,HLL_HASH diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md index db1b7437ca3..f45b54272cd 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md @@ -24,22 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_CARDINALITY -### description -#### Syntax +## Description -`HLL_CARDINALITY(hll)` +`HLL_CARDINALITY` calculates the cardinality of a HyperLogLog (HLL) type value. It is an approximate counting algorithm suitable for estimating the number of distinct elements in large datasets. -HLL_CARDINALITY is used to calculate the cardinality of a single HLL type value. +## Syntax -### example +```sql +HLL_CARDINALITY(<hll>) ``` -MySQL > select HLL_CARDINALITY(uv_set) from test_uv; + +## Parameters + +| Parameter | Description | +| ---------- | -------------------------------------------------------- | +| `<hll>` | The HLL type value representing the dataset whose cardinality needs to be estimated. | + +## Return Value + +Returns the estimated cardinality of the HLL type value, representing the number of distinct elements in the dataset. + +## Example + +```sql +select HLL_CARDINALITY(uv_set) from test_uv; +``` + +```text +---------------------------+ | hll_cardinality(`uv_set`) | +---------------------------+ | 3 | +---------------------------+ -``` -### keywords -HLL,HLL_CARDINALITY +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md index 776a7c3722e..75cc2b34805 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY -### description -#### Syntax +## Description -`HLL_EMPTY(value)` +`HLL_EMPTY` returns an empty HLL (HyperLogLog) value, representing a data set with no elements. -HLL_EMPTY returns a null value of type hll. +## Syntax -### example +```sql +HLL_EMPTY() ``` -MySQL > select hll_cardinality(hll_empty()); + +## Return Value + +Returns an empty HLL type value, representing a data set with no elements. + +## Example + +```sql +select hll_cardinality(hll_empty()); +``` + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md index c0efeb46449..8a25e148373 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md @@ -22,50 +22,68 @@ specific language governing permissions and limitations under the License. --> -## hll_from_base64 +## Description -### description -#### Syntax +Converts a base64-encoded string (usually the result of the `HLL_TO_BASE64` function) into an HLL. If the input string is invalid or NULL, the function returns NULL. -`HLL HLL_FROM_BASE64(VARCHAR input)` +## Syntax -Convert a base64 string(result of function `hll_to_base64`) into a hll. If input string is invalid, return NULL. +```sql +HLL_FROM_BASE64(<input>) +``` + +## Parameters -### example +| Parameter | Description | +| --------- | --------------------------------------------------------------------------- | +| `<input>` | A base64-encoded string, typically generated by the `HLL_TO_BASE64` function. If the input string is invalid or NULL, the function returns NULL. | +## Examples + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; ``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; + +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +``` + +```text +---------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))) | +---------------------------------------------------------------+ | 1 | +---------------------------------------------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +``` + +```text +-----------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))) | +-----------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------+ -1 row in set (0.02 sec) -``` - -### keywords -HLL_FROM_BASE64, HLL +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md index b174e6236e8..d2df2cd4016 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md @@ -24,23 +24,32 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH -### description -#### Syntax +## Description -`HLL_HASH(value)` +Converts a given value to the HLL (HyperLogLog) type. This function is typically used during data loading to create an HLL from raw data. -HLL_HASH converts a value to hll type. -Typically used when loading data. +## Syntax -### example +```sql +HLL_HASH(<value>) ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +## Parameters + +| Parameter | Description | +|-----------|---------------------------------------------------------------| +| `<value>` | The value to be converted to HLL type. This can be a string, number, or any data type. | + +## Examples + +```sql +SELECT HLL_CARDINALITY(HLL_HASH('abc')); +``` + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ ``` -### keywords -HLL,HLL_HASH diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md index 6da0051d84c..21e006692e7 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md @@ -1,8 +1,12 @@ +根据您提供的规范,我将重新整理文档: + --- + { "title": "HLL_TO_BASE64", "language": "en" } + --- <!-- @@ -22,58 +26,80 @@ specific language governing permissions and limitations under the License. --> -## hll_to_base64 +## Description -### description -#### Syntax +Converts an input HLL to a base64-encoded string. If the input is `<null>`, the function returns `<null>`. + +## Syntax + +```sql +HLL_TO_BASE64(<hll_input>) +``` -`VARCHAR HLL_TO_BASE64(HLL input)` +## Parameters -Convert an input hll to a base64 string. If input is NULL, return NULL. +| Parameter | Description | +| ------------ | ---------------------------------------------------- | +| `<hll_input>` | The HyperLogLog (HLL) data to be converted to a base64-encoded string. If the input is `<null>`, the function returns `<null>`. | -### example +## Examples +```sql +select hll_to_base64(NULL); ``` -mysql> select hll_to_base64(NULL); + +```text +---------------------+ | hll_to_base64(NULL) | +---------------------+ | NULL | +---------------------+ -1 row in set (0.00 sec) +``` -mysql> select hll_to_base64(hll_empty()); +```sql +select hll_to_base64(hll_empty()); +``` + +```text +----------------------------+ | hll_to_base64(hll_empty()) | +----------------------------+ | AA== | +----------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_to_base64(hll_hash('abc')); +```sql +select hll_to_base64(hll_hash('abc')); +``` + +```text +--------------------------------+ | hll_to_base64(hll_hash('abc')) | +--------------------------------+ | AQEC5XSzrpDsdw== | +--------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) -``` - -### keywords -HLL_TO_BASE64, HLL +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md index db1b7437ca3..f45b54272cd 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-cardinality.md @@ -24,22 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_CARDINALITY -### description -#### Syntax +## Description -`HLL_CARDINALITY(hll)` +`HLL_CARDINALITY` calculates the cardinality of a HyperLogLog (HLL) type value. It is an approximate counting algorithm suitable for estimating the number of distinct elements in large datasets. -HLL_CARDINALITY is used to calculate the cardinality of a single HLL type value. +## Syntax -### example +```sql +HLL_CARDINALITY(<hll>) ``` -MySQL > select HLL_CARDINALITY(uv_set) from test_uv; + +## Parameters + +| Parameter | Description | +| ---------- | -------------------------------------------------------- | +| `<hll>` | The HLL type value representing the dataset whose cardinality needs to be estimated. | + +## Return Value + +Returns the estimated cardinality of the HLL type value, representing the number of distinct elements in the dataset. + +## Example + +```sql +select HLL_CARDINALITY(uv_set) from test_uv; +``` + +```text +---------------------------+ | hll_cardinality(`uv_set`) | +---------------------------+ | 3 | +---------------------------+ -``` -### keywords -HLL,HLL_CARDINALITY +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md index 776a7c3722e..75cc2b34805 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-empty.md @@ -24,22 +24,30 @@ specific language governing permissions and limitations under the License. --> -## HLL_EMPTY -### description -#### Syntax +## Description -`HLL_EMPTY(value)` +`HLL_EMPTY` returns an empty HLL (HyperLogLog) value, representing a data set with no elements. -HLL_EMPTY returns a null value of type hll. +## Syntax -### example +```sql +HLL_EMPTY() ``` -MySQL > select hll_cardinality(hll_empty()); + +## Return Value + +Returns an empty HLL type value, representing a data set with no elements. + +## Example + +```sql +select hll_cardinality(hll_empty()); +``` + +```text +------------------------------+ | hll_cardinality(hll_empty()) | +------------------------------+ | 0 | +------------------------------+ -``` -### keywords -HLL,HLL_EMPTY +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md index c0efeb46449..8a25e148373 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-from-base64.md @@ -22,50 +22,68 @@ specific language governing permissions and limitations under the License. --> -## hll_from_base64 +## Description -### description -#### Syntax +Converts a base64-encoded string (usually the result of the `HLL_TO_BASE64` function) into an HLL. If the input string is invalid or NULL, the function returns NULL. -`HLL HLL_FROM_BASE64(VARCHAR input)` +## Syntax -Convert a base64 string(result of function `hll_to_base64`) into a hll. If input string is invalid, return NULL. +```sql +HLL_FROM_BASE64(<input>) +``` + +## Parameters -### example +| Parameter | Description | +| --------- | --------------------------------------------------------------------------- | +| `<input>` | A base64-encoded string, typically generated by the `HLL_TO_BASE64` function. If the input string is invalid or NULL, the function returns NULL. | +## Examples + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; ``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; + +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))); +``` + +```text +---------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('')))) | +---------------------------------------------------------------+ | 1 | +---------------------------------------------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))); +``` + +```text +-----------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash(NULL)))) | +-----------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------+ -1 row in set (0.02 sec) -``` - -### keywords -HLL_FROM_BASE64, HLL +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md index b174e6236e8..d2df2cd4016 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-hash.md @@ -24,23 +24,32 @@ specific language governing permissions and limitations under the License. --> -## HLL_HASH -### description -#### Syntax +## Description -`HLL_HASH(value)` +Converts a given value to the HLL (HyperLogLog) type. This function is typically used during data loading to create an HLL from raw data. -HLL_HASH converts a value to hll type. -Typically used when loading data. +## Syntax -### example +```sql +HLL_HASH(<value>) ``` -MySQL > select HLL_CARDINALITY(HLL_HASH('abc')); + +## Parameters + +| Parameter | Description | +|-----------|---------------------------------------------------------------| +| `<value>` | The value to be converted to HLL type. This can be a string, number, or any data type. | + +## Examples + +```sql +SELECT HLL_CARDINALITY(HLL_HASH('abc')); +``` + +```text +----------------------------------+ | hll_cardinality(HLL_HASH('abc')) | +----------------------------------+ | 1 | +----------------------------------+ ``` -### keywords -HLL,HLL_HASH diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md index 6da0051d84c..21e006692e7 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/hll-functions/hll-to-base64.md @@ -1,8 +1,12 @@ +根据您提供的规范,我将重新整理文档: + --- + { "title": "HLL_TO_BASE64", "language": "en" } + --- <!-- @@ -22,58 +26,80 @@ specific language governing permissions and limitations under the License. --> -## hll_to_base64 +## Description -### description -#### Syntax +Converts an input HLL to a base64-encoded string. If the input is `<null>`, the function returns `<null>`. + +## Syntax + +```sql +HLL_TO_BASE64(<hll_input>) +``` -`VARCHAR HLL_TO_BASE64(HLL input)` +## Parameters -Convert an input hll to a base64 string. If input is NULL, return NULL. +| Parameter | Description | +| ------------ | ---------------------------------------------------- | +| `<hll_input>` | The HyperLogLog (HLL) data to be converted to a base64-encoded string. If the input is `<null>`, the function returns `<null>`. | -### example +## Examples +```sql +select hll_to_base64(NULL); ``` -mysql> select hll_to_base64(NULL); + +```text +---------------------+ | hll_to_base64(NULL) | +---------------------+ | NULL | +---------------------+ -1 row in set (0.00 sec) +``` -mysql> select hll_to_base64(hll_empty()); +```sql +select hll_to_base64(hll_empty()); +``` + +```text +----------------------------+ | hll_to_base64(hll_empty()) | +----------------------------+ | AA== | +----------------------------+ -1 row in set (0.02 sec) +``` -mysql> select hll_to_base64(hll_hash('abc')); +```sql +select hll_to_base64(hll_hash('abc')); +``` + +```text +--------------------------------+ | hll_to_base64(hll_hash('abc')) | +--------------------------------+ | AQEC5XSzrpDsdw== | +--------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +``` -mysql> select hll_union_agg(hll_from_base64(hll_to_base64(pv))), hll_union_agg(pv) from test_hll; +```text +---------------------------------------------------+-------------------+ | hll_union_agg(hll_from_base64(hll_to_base64(pv))) | hll_union_agg(pv) | +---------------------------------------------------+-------------------+ | 3 | 3 | +---------------------------------------------------+-------------------+ -1 row in set (0.04 sec) +``` + +```sql +select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +``` -mysql> select hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))); +```text +------------------------------------------------------------------+ | hll_cardinality(hll_from_base64(hll_to_base64(hll_hash('abc')))) | +------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------+ -1 row in set (0.04 sec) -``` - -### keywords -HLL_TO_BASE64, HLL +``` \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org