Skip to content

Commit

Permalink
[Docs] update data types doc and fix some typo (apache#4712)
Browse files Browse the repository at this point in the history
* update data types doc and fix some typo

* update data types doc and fix some typo

Co-authored-by: lixueyan07 <[email protected]>
  • Loading branch information
Astralidea and lixueyan07 authored Oct 14, 2020
1 parent 96aeeac commit a605b31
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 42 deletions.
3 changes: 2 additions & 1 deletion docs/.vuepress/sidebar/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,15 @@ module.exports = [
directoryPath: "Data Types/",
children: [
"BIGINT",
"BITMAP",
"BOOLEAN",
"CHAR",
"DATE",
"DATETIME",
"DECIMAL",
"DOUBLE",
"FLOAT",
"HLL(HyperLogLog)",
"HLL",
"INT",
"SMALLINT",
"TINYINT",
Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/sidebar/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ module.exports = [
directoryPath: "Data Types/",
children: [
"BIGINT",
"BITMAP",
"BOOLEAN",
"CHAR",
"DATE",
Expand Down
48 changes: 48 additions & 0 deletions docs/en/sql-reference/sql-statements/Data Types/BITMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
{
"title": "BITMAP",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

#BITMAP
## Description
BITMAP

BITMAP cannot be used as a key column, and the aggregation type is BITMAP_UNION when building the table.
The user does not need to specify the length and default value. The length is controlled within the system according to the degree of data aggregation.
And the BITMAP column can only be queried or used by supporting functions such as bitmap_union_count, bitmap_union, and bitmap_hash.

The use of BITMAP in offline scenarios will affect the import speed. In the case of a large amount of data, the query speed will be slower than HLL and better than Count Distinct.
Note: If BITMAP does not use a global dictionary in real-time scenarios, using bitmap_hash() may cause an error of about one-thousandth.

## example

select hour, BITMAP_UNION_COUNT(pv) over(order by hour) uv from(
select hour, BITMAP_UNION(device_id) as pv
from metric_table -- Query the accumulated UV per hour
where datekey=20200922
group by hour order by 1
) final;

## keyword
BITMAP

This file was deleted.

49 changes: 49 additions & 0 deletions docs/en/sql-reference/sql-statements/Data Types/HLL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
{
"title": "HLL (HyperLogLog)",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

#HLL (HyperLogLog)
## Description
HLL

HLL cannot be used as a key column, and the aggregation type is HLL_UNION when create table.
The user does not need to specify the length and default value.
The length is controlled within the system according to the degree of data aggregation.
And HLL columns can only be queried or used through the matching hll_union_agg, hll_raw_agg, hll_cardinality, and hll_hash.

HLL is approximate count of distinct elements, and its performance is better than Count Distinct when the amount of data is large.
The error of HLL is usually around 1%, sometimes up to 2%.

## example

select hour, HLL_UNION_AGG(pv) over(order by hour) uv from(
select hour, HLL_RAW_AGG(device_id) as pv
from metric_table -- Query the accumulated UV per hour
where datekey=20200922
group by hour order by 1
) final;

## keyword
HLL,HYPERLOGLOG
4 changes: 3 additions & 1 deletion docs/en/sql-reference/sql-statements/Data Types/VARCHAR.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ under the License.
# VARCHAR
## Description
MARKETING (M)
A variable length string, M represents the length of a variable length string. The range of M is 1-65535.
A variable length string, M represents the length of a variable length string. The range of M is 1-65533.

Note: Variable length strings are stored in UTF-8 encoding, so usually English characters occupies 1 byte, and Chinese characters occupies 3 bytes.

## keyword
VARCHAR
48 changes: 48 additions & 0 deletions docs/zh-CN/sql-reference/sql-statements/Data Types/BITMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
{
"title": "BITMAP",
"language": "zh-CN"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# BITMAP
## description
BITMAP
BITMAP不能作为key列使用,建表时配合聚合类型为BITMAP_UNION。
用户不需要指定长度和默认值。长度根据数据的聚合程度系统内控制。
并且BITMAP列只能通过配套的bitmap_union_count、bitmap_union、bitmap_hash等函数进行查询或使用。

离线场景下使用BITMAP会影响导入速度,在数据量大的情况下查询速度会慢于HLL,并优于Count Distinct。
注意:实时场景下BITMAP如果不使用全局字典,使用了bitmap_hash()可能会导致有千分之一左右的误差。

## example

select hour, BITMAP_UNION_COUNT(pv) over(order by hour) uv from(
select hour, BITMAP_UNION(device_id) as pv
from metric_table -- 查询每小时的累计UV
where datekey=20200622
group by hour order by 1
) final;

## keyword

BITMAP
20 changes: 16 additions & 4 deletions docs/zh-CN/sql-reference/sql-statements/Data Types/HLL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@ under the License.

# HLL(HyperLogLog)
## description
VARCHAR(M)
变长字符串,M代表的是变长字符串的长度。M的范围是1-16385
用户不需要指定长度和默认值。长度根据数据的聚合程度系统内控制
并且HLL列只能通过配套的hll_union_agg、hll_raw_agg、hll_cardinality、hll_hash进行查询或使用
HLL
HLL不能作为key列使用,建表时配合聚合类型为HLL_UNION。
用户不需要指定长度和默认值。长度根据数据的聚合程度系统内控制。
并且HLL列只能通过配套的hll_union_agg、hll_raw_agg、hll_cardinality、hll_hash进行查询或使用。

HLL是模糊去重,在数据量大的情况性能优于Count Distinct。
HLL的误差通常在1%左右,有时会达到2%。

## example

select hour, HLL_UNION_AGG(pv) over(order by hour) uv from(
select hour, HLL_RAW_AGG(device_id) as pv
from metric_table -- 查询每小时的累计UV
where datekey=20200622
group by hour order by 1
) final;

## keyword

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ under the License.
# VARCHAR
## description
VARCHAR(M)
变长字符串,M代表的是变长字符串的长度。M的范围是1-65535
变长字符串,M代表的是变长字符串的长度。M的范围是1-65533。

注意:变长字符串是以UTF-8编码存储的,因此通常英文字符占1个字节,中文字符占3个字节。

## keyword

Expand Down

0 comments on commit a605b31

Please sign in to comment.