From 2b55bbe009672feb5def6bee9ac8e0493568dd1a Mon Sep 17 00:00:00 2001 From: catpineapple <1391869588@qq.com> Date: Wed, 22 Jan 2025 10:58:55 +0800 Subject: [PATCH] [doc](sql) bitmap-1 func (#1852) ## Versions - [x] dev - [x] 3.0 - [x] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --- .../bitmap-functions/bitmap-and-count.md | 65 +++++++++------ .../bitmap-functions/bitmap-and-not-count.md | 54 ++++++++++--- .../bitmap-functions/bitmap-and-not.md | 60 ++++++++++---- .../bitmap-functions/bitmap-and.md | 76 ++++++++--------- .../bitmap-functions/bitmap-contains.md | 51 +++++++----- .../bitmap-functions/bitmap-count.md | 38 +++++---- .../bitmap-functions/bitmap-empty.md | 44 ++++++---- .../bitmap-functions/bitmap-from-array.md | 49 ++++++----- .../bitmap-functions/bitmap-from-base64.md | 77 +++++++++++------- .../bitmap-functions/bitmap-from-string.md | 81 ++++++++++++------- .../bitmap-functions/bitmap-and-count.md | 61 ++++++++------ .../bitmap-functions/bitmap-and-not-count.md | 47 ++++++++--- .../bitmap-functions/bitmap-and-not.md | 55 ++++++++++--- .../bitmap-functions/bitmap-and.md | 68 ++++++++-------- .../bitmap-functions/bitmap-contains.md | 45 ++++++----- .../bitmap-functions/bitmap-count.md | 33 ++++---- .../bitmap-functions/bitmap-empty.md | 41 ++++++---- .../bitmap-functions/bitmap-from-array.md | 44 +++++----- .../bitmap-functions/bitmap-from-base64.md | 73 +++++++++++------ .../bitmap-functions/bitmap-from-string.md | 77 +++++++++++------- .../bitmap-functions/bitmap-and-count.md | 61 ++++++++------ .../bitmap-functions/bitmap-and-not-count.md | 47 ++++++++--- .../bitmap-functions/bitmap-and-not.md | 55 ++++++++++--- .../bitmap-functions/bitmap-and.md | 68 ++++++++-------- .../bitmap-functions/bitmap-contains.md | 45 ++++++----- .../bitmap-functions/bitmap-count.md | 33 ++++---- .../bitmap-functions/bitmap-empty.md | 41 ++++++---- .../bitmap-functions/bitmap-from-array.md | 44 +++++----- .../bitmap-functions/bitmap-from-base64.md | 73 +++++++++++------ .../bitmap-functions/bitmap-from-string.md | 77 +++++++++++------- .../bitmap-functions/bitmap-and-count.md | 61 ++++++++------ .../bitmap-functions/bitmap-and-not-count.md | 47 ++++++++--- .../bitmap-functions/bitmap-and-not.md | 55 ++++++++++--- .../bitmap-functions/bitmap-and.md | 68 ++++++++-------- .../bitmap-functions/bitmap-contains.md | 45 ++++++----- .../bitmap-functions/bitmap-count.md | 33 ++++---- .../bitmap-functions/bitmap-empty.md | 41 ++++++---- .../bitmap-functions/bitmap-from-array.md | 44 +++++----- .../bitmap-functions/bitmap-from-base64.md | 73 +++++++++++------ .../bitmap-functions/bitmap-from-string.md | 77 +++++++++++------- .../bitmap-functions/bitmap-and-count.md | 65 +++++++++------ .../bitmap-functions/bitmap-and-not-count.md | 54 ++++++++++--- .../bitmap-functions/bitmap-and-not.md | 60 ++++++++++---- .../bitmap-functions/bitmap-and.md | 76 ++++++++--------- .../bitmap-functions/bitmap-contains.md | 51 +++++++----- .../bitmap-functions/bitmap-count.md | 38 +++++---- .../bitmap-functions/bitmap-empty.md | 44 ++++++---- .../bitmap-functions/bitmap-from-array.md | 49 ++++++----- .../bitmap-functions/bitmap-from-base64.md | 77 +++++++++++------- .../bitmap-functions/bitmap-from-string.md | 81 ++++++++++++------- .../bitmap-functions/bitmap-and-count.md | 65 +++++++++------ .../bitmap-functions/bitmap-and-not-count.md | 54 ++++++++++--- .../bitmap-functions/bitmap-and-not.md | 60 ++++++++++---- .../bitmap-functions/bitmap-and.md | 76 ++++++++--------- .../bitmap-functions/bitmap-contains.md | 51 +++++++----- .../bitmap-functions/bitmap-count.md | 38 +++++---- .../bitmap-functions/bitmap-empty.md | 44 ++++++---- .../bitmap-functions/bitmap-from-array.md | 49 ++++++----- .../bitmap-functions/bitmap-from-base64.md | 77 +++++++++++------- .../bitmap-functions/bitmap-from-string.md | 81 ++++++++++++------- 60 files changed, 2115 insertions(+), 1302 deletions(-) diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md index 14991554520dc..840f9bb600430 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md @@ -24,54 +24,70 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_count -### description -#### Syntax +## Description -`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)` +Computes the intersection of two or more input BITMAPs and returns the number of intersections. -Calculate the intersection of two or more input bitmaps and return the number of intersections. - -### example +## Syntax +```sql +BITMAP_AND_COUNT(, ,[, ...]) ``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_empty()); -+---------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_empty()) | -+---------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------+ +## Parameters -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3')); -+----------------------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) | -+----------------------------------------------------------------------------+ -| 3 | -+----------------------------------------------------------------------------+ +| Parameter | Description | +|------------|----------------------------------------------------------------| +| `` | One of the original BITMAPs whose intersection is being sought | + +## Return Value -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +Returns an integer +- If the parameter has a null value, it returns NULL + +## Examples + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +``` + +```text +----------------------------------------------------------------------------+ | bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) | +----------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------+ +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +``` + +```text +-------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-------------------------------------------------------------------------------------------------------------+ | 2 | +-------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +-----------------------------------------------------------------------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +```text +-------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-------------------------------------------------------------------------------------------------------------------+ @@ -79,6 +95,3 @@ MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string(' +-------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - - BITMAP_AND_COUNT,BITMAP diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md index 11695a9e4e2b0..1e3e563b62884 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md @@ -24,26 +24,54 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not_count,bitmap_andnot_count -### description -#### Syntax +## Description -`BITMAP BITMAP_AND_NOT_COUNT(BITMAP lhs, BITMAP rhs)` +Performs a NOT operation on two BITMAPs and returns the number of elements in the result set. The first input parameter is called `base BITMAP` and the second is called `exclusion BITMAP`. -Calculate the set after lhs minus intersection of two input bitmaps, return the new bitmap size. +## Alias +- BITMAP_ANDNOT_COUNT -### example +## Syntax +```sql +BITMAP_AND_NOT_COUNT(, ) ``` -mysql> select bitmap_and_not_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) cnt; + +## Parameters + +| Parameter | Description | +|-------------|----------------------------------| +| `` | `Base BITMAP` to be negated | +| `` | `Exclusion BITMAP` to be negated | + +## Return Value + +Returns an integer. +- If the parameter has a null value, returns NULL + +## Examples + +```sql +select bitmap_and_not_count(null, bitmap_from_string('1,2,3')) banc1, bitmap_and_not_count(bitmap_from_string('1,2,3') ,null) banc2; +``` + +```text ++-------+-------+ +| banc1 | banc2 | ++-------+-------+ +| 0 | 0 | ++-------+-------+ +``` + +```sql +select bitmap_and_not_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) banc; +``` + +```text +------+ -| cnt | +| banc | +------+ | 2 | +------+ -``` - -### keywords - - BITMAP_AND_NOT_COUNT,BITMAP_ANDNOT_COUNT,BITMAP +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md index beee61656dcce..b7abb3e6d964d 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md @@ -24,46 +24,78 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not,bitmap_andnot -### description -#### Syntax +## Description -`BITMAP BITMAP_AND_NOT(BITMAP lhs, BITMAP rhs)` +Perform a NOT operation on two BITMAPs and return the result. The first input parameter is called `base BITMAP` and the second is called `exclude BITMAP`. -Calculate the set after lhs minus intersection of two input bitmaps, return the new bitmap. +## Alias -### example +- BITMAP_ANDNOT +## Syntax + +```sql +BITMAP_AND_NOT(, ) +``` + +## Parameters + +| Parameter | Description | +|-------------|----------------------------------| +| `` | `Base BITMAP` to be negated | +| `` | `Exclusion BITMAP` to be negated | + +## Return Value + +Returns a BITMAP. +- If the parameter has a null value, returns NULL + +## Examples + +```sql +select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; ``` -mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; + +```text +------+ | cnt | +------+ | 2 | +------+ +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +``` + +```text +--------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) | +--------------------------------------------------------------------------------------------+ | 1,2 | +--------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ; +```text +-------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) | +-------------------------------------------------------------------------------+ | 1,2,3 | +-------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +```text +---------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) | +---------------------------------------------------------------------+ | NULL | +---------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND_NOT,BITMAP_ANDNOT,BITMAP diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md index b638a31dcd55d..99630843af578 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md @@ -24,67 +24,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and -### description -#### Syntax +## Description -`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs, ...)` +Computes the intersection of two or more input BITMAPs and returns a new BITMAP. -Compute intersection of two or more input bitmaps, return the new bitmap. +## Syntax -### example +```sql +BITMAP_AND(, ,[, ...]) +``` + +## Parameters + +| Parameter | Description | +|------------|----------------------------------------------------------------| +| `` | One of the original BITMAPs whose intersection is being sought | + +## Return Value +Returns a BITMAP +- If the parameter has a null value, it returns NULL + +## Examples + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); ``` -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) | -+----------------------------------------------------------+ -| | -+----------------------------------------------------------+ - -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ - -MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ - -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); + +```text +-----------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-----------------------------------------------------------------------------------------------------------------------+ | 1,2 | +-----------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +``` + +```text +---------------------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +---------------------------------------------------------------------------------------------------------------------------------------+ | | +---------------------------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-----------------------------------------------------------------------------------------------------------------------------+ | NULL | +-----------------------------------------------------------------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND,BITMAP diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md index 01b8e665cb320..4cf5f7fd04140 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md @@ -24,32 +24,39 @@ specific language governing permissions and limitations under the License. --> -## bitmap_contains -### description -#### Syntax +## Description -`BOOLEAN BITMAP_CONTAINS(BITMAP bitmap, BIGINT input)` +Calculates whether the input value is in the BITMAP and returns a boolean value. -Calculates whether the input value is in the Bitmap column and returns a Boolean value. - -### example +## Syntax +```sql +BITMAP_CONTAINS(, ) ``` -mysql> select bitmap_contains(to_bitmap(1),2) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_contains(to_bitmap(1),1) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ + +## Parameters + +| Parameter | Description | +|------------|-----------------------------------------| +| `` | BITMAP collection | +| `` | The integer to be checked for existence | + +## Return Value + +Returns a boolean +- If the parameter is empty, returns NULL + +## Examples + +```sql +select bitmap_contains(to_bitmap(1),2) cnt1, bitmap_contains(to_bitmap(1),1) cnt2; ``` -### keywords +```text ++------+------+ +| cnt1 | cnt2 | ++------+------+ +| 0 | 1 | ++------+------+ +``` - BITMAP_CONTAINS,BITMAP diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md index fb90c995890e5..ccb9e3f66b083 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md @@ -24,33 +24,37 @@ specific language governing permissions and limitations under the License. --> -## bitmap_count -### description -#### Syntax +## Description -`BITMAP BITMAP_COUNT(BITMAP lhs)` +Count the number of elements in the input BITMAP -Returns the number of input bitmaps. +## Syntax -### example +```sql +BITMAP_COUNT() +``` + +## Parameters + +| Parameter | Description | +|------------|-------------| +| `` | a BITMAP | + +## Return Value +Returns an integer + +## Examples + +```sql +select bitmap_count(to_bitmap(1)) cnt; ``` -mysql> select bitmap_count(to_bitmap(1)) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; +```text +------+ | cnt | +------+ | 1 | +------+ - ``` -### keywords - - BITMAP_COUNT diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md index 291f926ec2195..429dcfc945e76 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md @@ -24,29 +24,31 @@ specific language governing permissions and limitations under the License. --> -## bitmap_empty -### description -#### Syntax +## Description -`BITMAP BITMAP_EMPTY()` - -Return an empty bitmap. Mainly be used to supply default value for bitmap column when loading, e.g., +Construct an empty BITMAP. Mainly used to fill default values during insert or stream load. For example: ``` -cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://host:8410/api/test/testDb/_stream_load +cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://127.0.0.1:8040/api/test_database/test_table/_stream_load ``` -### example +## Syntax +```sql +BITMAP_EMPTY() ``` -mysql> select bitmap_count(bitmap_empty()); -+------------------------------+ -| bitmap_count(bitmap_empty()) | -+------------------------------+ -| 0 | -+------------------------------+ -mysql> select bitmap_to_string(bitmap_empty()); +## Return Value + +Returns an empty array with no elements + +## Examples + +```sql +select bitmap_to_string(bitmap_empty()); +``` + +```text +----------------------------------+ | bitmap_to_string(bitmap_empty()) | +----------------------------------+ @@ -54,6 +56,14 @@ mysql> select bitmap_to_string(bitmap_empty()); +----------------------------------+ ``` -### keywords +```sql +select bitmap_count(bitmap_empty()); +``` - BITMAP_EMPTY,BITMAP +```text ++------------------------------+ +| bitmap_count(bitmap_empty()) | ++------------------------------+ +| 0 | ++------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md index 6ba524d46733c..dda3105a861ff 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md @@ -22,32 +22,37 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_array +## Description -### description -#### Syntax +Converts an array of TINYINT/SMALLINT/INT/BIGINT type to a BITMAP. When the input field is illegal, the result returns NULL. -`BITMAP BITMAP_FROM_ARRAY(ARRAY input)` +## Syntax -Convert a TINYINT/SMALLINT/INT/BIGINT array to a BITMAP -When the input field is illegal, the result returns NULL +```sql +BITMAP_FROM_ARRAY() +``` -### example +## Parameters -``` -mysql> select *, bitmap_to_string(bitmap_from_array(c_array)) from array_test; -+------+-----------------------+------------------------------------------------+ -| id | c_array | bitmap_to_string(bitmap_from_array(`c_array`)) | -+------+-----------------------+------------------------------------------------+ -| 1 | [NULL] | NULL | -| 2 | [1, 2, 3, NULL] | NULL | -| 2 | [1, 2, 3, -10] | NULL | -| 3 | [1, 2, 3, 4, 5, 6, 7] | 1,2,3,4,5,6,7 | -| 4 | [100, 200, 300, 300] | 100,200,300 | -+------+-----------------------+------------------------------------------------+ -5 rows in set (0.02 sec) -``` +| Parameter | Description | +|-----------|---------------| +| `` | integer array | + +## Return Value -### keywords +Returns a BITMAP +- When the input field is invalid, the result is NULL + +## Examples + +```sql +SELECT bitmap_to_string(bitmap_from_array(array(1, 0, 1, 1, 0, 1, 0))) AS bs; +``` - BITMAP_FROM_ARRAY,BITMAP +```text ++------+ +| bs | ++------+ +| 0,1 | ++------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md index 4a60f9e5fc9d0..5c2278edff910 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md @@ -22,40 +22,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_base64 +## Description -### description -#### Syntax +Convert a base64 string (which can be converted by `bitmap_to_base64` function) to a BITMAP. Returns NULL when the input string is invalid. -`BITMAP BITMAP_FROM_BASE64(VARCHAR input)` +## Syntax -Convert a base64 string(result of function `bitmap_to_base64`) into a bitmap. If input string is invalid, return NULL. +```sql + BITMAP_FROM_BASE64() +``` + +## Parameters + +| Parameter | Description | +|----------------|-----------------------------------------------------------------| +| `` | base64 string (can be converted by `bitmap_to_base64` function) | + +## Return Value + +Returns a BITMAP +- When the input field is invalid, the result is NULL + +## Examples -### example +```sql +select bitmap_to_string(bitmap_from_base64("AA==")) bts; +``` + +```text ++------+ +| bts | ++------+ +| | ++------+ +``` +```sql +select bitmap_to_string(bitmap_from_base64("AQEAAAA=")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_base64("AA==")); -+----------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AA==")) | -+----------------------------------------------+ -| | -+----------------------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AQEAAAA=")); -+-----------------------------------+ -| bitmap_to_string(bitmap_from_base64("AQEAAAA=")) | -+-----------------------------------+ -| 1 | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")); -+----------------------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) | -+----------------------------------------------------------------------------------+ -| 1,9999999 | -+----------------------------------------------------------------------------------+ + +```text ++------+ +| bts | ++------+ +| 1 | ++------+ ``` -### keywords +```sql +select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) bts; +``` - BITMAP_FROM_BASE64,BITMAP +```text ++-----------+ +| bts | ++-----------+ +| 1,9999999 | ++-----------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md index 672306960b0b4..e835d895d9075 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md +++ b/docs/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md @@ -22,42 +22,63 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_string +## Description -### description -#### Syntax +Convert a string into a BITMAP. The string consists of a group of unsigned bigint numbers separated by commas. (The number values are between: 0 ~ 18446744073709551615) +For example, the string "0, 1, 2" will be converted into a Bitmap, where the 0th, 1st, and 2nd bits are set. When the input field is invalid, NULL is returned -`BITMAP BITMAP_FROM_STRING(VARCHAR input)` +## Syntax -Convert a string into a bitmap. The input string should be a comma separated unsigned bigint (ranging from 0 to 18446744073709551615). -For example: input string "0, 1, 2" will be converted to a Bitmap with bit 0, 1, 2 set. -If input string is invalid, return NULL. +```sql + BITMAP_FROM_STRING() +``` + +## Parameters + +| Parameter | Description | +|-----------|------------------------------------------------------------------------------------------------| +| `` | Array string, for example "0, 1, 2" string will be converted to a Bitmap with bits 0, 1, 2 set | + +## Return Value -### example +Returns a BITMAP +- When the input field is invalid, the result is NULL +## Examples + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 2")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 2")); -+-------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 2')) | -+-------------------------------------------------+ -| 0,1,2 | -+-------------------------------------------------+ - -mysql> select bitmap_from_string("-1, 0, 1, 2"); -+-----------------------------------+ -| bitmap_from_string('-1, 0, 1, 2') | -+-----------------------------------+ -| NULL | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")); -+--------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 18446744073709551615')) | -+--------------------------------------------------------------------+ -| 0,1,18446744073709551615 | -+--------------------------------------------------------------------+ + +```text ++-------+ +| bts | ++-------+ +| 0,1,2 | ++-------+ ``` -### keywords +```sql +select bitmap_from_string("-1, 0, 1, 2") bfs; +``` + +```text ++------+ +| bfs | ++------+ +| NULL | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")) bts; +``` + +```text ++--------------------------+ +| bts | ++--------------------------+ +| 0,1,18446744073709551615 | ++--------------------------+ +``` - BITMAP_FROM_STRING,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md index d1195d50ac5d4..ea8740d957b08 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md @@ -24,54 +24,70 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_count ## 描述 + +计算两个及以上输入 BITMAP 的交集,返回交集的个数. + ## 语法 -`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)` +```sql +BITMAP_AND_COUNT(, ,[, ...]) +``` -计算两个及以上输入bitmap的交集,返回交集的个数. +## 参数 -## 举例 +| 参数 | 说明 | +|------------|------------------| +| `` | 被求交集的原 BITMAP 之一 | -``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_empty()); -+---------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_empty()) | -+---------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------+ +## 返回值 +返回整数 +- 当参数存在空值时,返回 NULL -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3')); -+----------------------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) | -+----------------------------------------------------------------------------+ -| 3 | -+----------------------------------------------------------------------------+ +## 举例 + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +```text +----------------------------------------------------------------------------+ | bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) | +----------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +```text +-------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-------------------------------------------------------------------------------------------------------------+ | 2 | +-------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +-----------------------------------------------------------------------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +``` + +```text +-------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-------------------------------------------------------------------------------------------------------------------+ @@ -79,6 +95,3 @@ MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string(' +-------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - - BITMAP_AND_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md index d815ce04c58a6..5525020465baf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md @@ -24,25 +24,54 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not_count,bitmap_andnot_count ## 描述 + +将两个 BITMAP 进行与非操作并返回计算结果集的元素个数,其中入参第一个叫 `基准 BITMAP`, 第二个叫 `排除 BITMAP`。 + +## 别名 + +- BITMAP_ANDNOT_COUNT + ## 语法 -`BITMAP BITMAP_AND_NOT_COUNT(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND_NOT_COUNT(, ) +``` + +## 参数 + +| 参数 | 说明 | +|-------------|------------------| +| `` | 被求与非的`基准 BITMAP` | +| `` | 被求与非的`排除 BITMAP` | + +## 返回值 -将两个bitmap进行与非操作并返回计算返回的大小. +返回整数。 +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_and_not_count(null, bitmap_from_string('1,2,3')) banc1, bitmap_and_not_count(bitmap_from_string('1,2,3') ,null) banc2; ``` -mysql> select bitmap_and_not_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) cnt; + +```text ++-------+-------+ +| banc1 | banc2 | ++-------+-------+ +| 0 | 0 | ++-------+-------+ +``` + +```sql +select bitmap_and_not_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) banc; +``` + +```text +------+ -| cnt | +| banc | +------+ | 2 | +------+ ``` - -### keywords - - BITMAP_AND_NOT_COUNT,BITMAP_ANDNOT_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md index 5161d373cf4c1..0a2f8306d2870 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md @@ -24,47 +24,78 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not,bitmap_andnot ## 描述 + +将两个 BITMAP 进行与非操作并返回计算结果,其中入参第一个叫 `基准 BITMAP`, 第二个叫 `排除 BITMAP`。 + +## 别名 + +- BITMAP_ANDNOT + ## 语法 -`BITMAP BITMAP_AND_NOT(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND_NOT(, ) +``` + +## 参数 + +| 参数 | 说明 | +|-------------|------------------| +| `` | 被求与非的`基准 BITMAP` | +| `` | 被求与非的`排除 BITMAP` | + +## 返回值 -将两个bitmap进行与非操作并返回计算结果。 +返回一个 BITMAP。 +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; ``` -mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; + +```text +------+ | cnt | +------+ | 2 | +------+ +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +``` + +```text +--------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) | +--------------------------------------------------------------------------------------------+ | 1,2 | +--------------------------------------------------------------------------------------------+ -1 row in set (0.01 sec) +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ; +```text +-------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) | +-------------------------------------------------------------------------------+ | 1,2,3 | +-------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +```text +---------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) | +---------------------------------------------------------------------+ | NULL | +---------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND_NOT,BITMAP_ANDNOT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md index 5a375d519fd43..4773342d152a7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md @@ -24,60 +24,58 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and ## 描述 + +计算两个及以上输入的 BITMAP 的交集,返回新的 BITMAP. + ## 语法 -`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND(, ,[, ...]) +``` + +## 参数 -计算两个及以上输入bitmap的交集,返回新的bitmap. +| 参数 | 说明 | +|------------|------------------| +| `` | 被求交集的原 BITMAP 之一 | + +## 返回值 + +返回一个 BITMAP +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); ``` -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) | -+----------------------------------------------------------+ -| | -+----------------------------------------------------------+ - -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ - -MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ - -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); + +```text +-----------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-----------------------------------------------------------------------------------------------------------------------+ | 1,2 | +-----------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +```text +---------------------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +---------------------------------------------------------------------------------------------------------------------------------------+ | | +---------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-----------------------------------------------------------------------------------------------------------------------------+ @@ -85,6 +83,4 @@ MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_fr +-----------------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - BITMAP_AND,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md index 459fe27f792c2..9a2e978bbbddf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md @@ -24,32 +24,39 @@ specific language governing permissions and limitations under the License. --> -## bitmap_contains ## 描述 + +计算输入值是否在 BITMAP 中,返回值是 boolean 值. + ## 语法 -`BOOLEAN BITMAP_CONTAINS(BITMAP bitmap, BIGINT input)` +```sql +BITMAP_CONTAINS(, ) +``` + +## 参数 -计算输入值是否在Bitmap列中,返回值是Boolean值. +| 参数 | 说明 | +|------------|------------| +| `` | BITMAP 集合 | +| `` | 被判断是否存在的整数 | + +## 返回值 + +返回一个 boolean +- 当参数存在空时,返回 NULL ## 举例 -``` -mysql> select bitmap_contains(to_bitmap(1),2) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_contains(to_bitmap(1),1) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ +```sql +select bitmap_contains(to_bitmap(1),2) cnt1, bitmap_contains(to_bitmap(1),1) cnt2; ``` -### keywords +```text ++------+------+ +| cnt1 | cnt2 | ++------+------+ +| 0 | 1 | ++------+------+ +``` - BITMAP_CONTAINS,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md index 6ac20407e0a7e..e8c74a86b7dd0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md @@ -24,33 +24,36 @@ specific language governing permissions and limitations under the License. --> -## bitmap_count ## 描述 + +计算输入 BITMAP 的元素个数 + ## 语法 -`BITMAP BITMAP_COUNT(BITMAP lhs)` +```sql +BITMAP_COUNT() +``` + +## 参数 -返回输入bitmap的个数。 +| 参数 | 说明 | +|------------|------------| +| `` | BITMAP 集合 | + +## 返回值 + +返回一个整数 ## 举例 +```sql +select bitmap_count(to_bitmap(1)) cnt; ``` -mysql> select bitmap_count(to_bitmap(1)) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; +```text +------+ | cnt | +------+ | 1 | +------+ - ``` - -### keywords - - BITMAP_COUNT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md index c692447e84a55..7f9141c3ef18e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md @@ -24,37 +24,46 @@ specific language governing permissions and limitations under the License. --> -## bitmap_empty ## 描述 -## 语法 - -`BITMAP BITMAP_EMPTY()` -返回一个空bitmap。主要用于 insert 或 stream load 时填充默认值。例如 +构建一个空 BITMAP。主要用于 insert 或 stream load 时填充默认值。例如: ``` -cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://host:8410/api/test/testDb/_stream_load +cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://127.0.0.1:8040/api/test_database/test_table/_stream_load +``` + +## 语法 + +```sql +BITMAP_EMPTY() ``` +## 返回值 + +返回一个无元素的空 BITMAP。 + ## 举例 +```sql +select bitmap_to_string(bitmap_empty()); ``` -mysql> select bitmap_count(bitmap_empty()); -+------------------------------+ -| bitmap_count(bitmap_empty()) | -+------------------------------+ -| 0 | -+------------------------------+ -mysql> select bitmap_to_string(bitmap_empty()); +```text +----------------------------------+ | bitmap_to_string(bitmap_empty()) | +----------------------------------+ | | +----------------------------------+ - ``` -### keywords +```sql +select bitmap_count(bitmap_empty()); +``` - BITMAP_EMPTY,BITMAP +```text ++------------------------------+ +| bitmap_count(bitmap_empty()) | ++------------------------------+ +| 0 | ++------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md index 7efe53b77f919..04935baafaa67 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md @@ -22,32 +22,38 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_array - ## 描述 + +将一个 TINYINT/SMALLINT/INT/BIGINT 类型的数组转化为一个 BITMAP,当输入字段不合法时,结果返回 NULL + ## 语法 -`BITMAP BITMAP_FROM_ARRAY(ARRAY input)` +```sql +BITMAP_FROM_ARRAY() +``` + +## 参数 -将一个TINYINT/SMALLINT/INT/BIGINT类型的数组转化为一个BITMAP -当输入字段不合法时,结果返回NULL +| 参数 | 说明 | +|---------|------| +| `` | 整形数组 | + +## 返回值 + +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 -``` -mysql> select *, bitmap_to_string(bitmap_from_array(c_array)) from array_test; -+------+-----------------------+------------------------------------------------+ -| id | c_array | bitmap_to_string(bitmap_from_array(`c_array`)) | -+------+-----------------------+------------------------------------------------+ -| 1 | [NULL] | NULL | -| 2 | [1, 2, 3, NULL] | NULL | -| 2 | [1, 2, 3, -10] | NULL | -| 3 | [1, 2, 3, 4, 5, 6, 7] | 1,2,3,4,5,6,7 | -| 4 | [100, 200, 300, 300] | 100,200,300 | -+------+-----------------------+------------------------------------------------+ -5 rows in set (0.02 sec) +```sql +SELECT bitmap_to_string(bitmap_from_array(array(1, 0, 1, 1, 0, 1, 0))) AS bs; ``` -### keywords +```text ++------+ +| bs | ++------+ +| 0,1 | ++------+ +``` - BITMAP_FROM_ARRAY,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md index 2a372f1cdb246..3ed2126d32a5b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md @@ -22,40 +22,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_base64 - ## 描述 + +将一个 base64 字符串(可以由 `bitmap_to_base64` 函数转换来)转化为一个 BITMAP。当输入字符串不合法时,返回 NULL。 + ## 语法 -`BITMAP BITMAP_FROM_BASE64(VARCHAR input)` +```sql + BITMAP_FROM_BASE64() +``` + +## 参数 + +| 参数 | 说明 | +|----------------|----------------------------------------| +| `` | base64 字符串(可以由`bitmap_to_base64`函数转换来) | + +## 返回值 -将一个base64字符串(`bitmap_to_base64`函数的结果)转化为一个BITMAP。当输入字符串不合法时,返回NULL。 +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_from_base64("AA==")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_base64("AA==")); -+----------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AA==")) | -+----------------------------------------------+ -| | -+----------------------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AQEAAAA=")); -+-----------------------------------+ -| bitmap_to_string(bitmap_from_base64("AQEAAAA=")) | -+-----------------------------------+ -| 1 | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")); -+----------------------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) | -+----------------------------------------------------------------------------------+ -| 1,9999999 | -+----------------------------------------------------------------------------------+ + +```text ++------+ +| bts | ++------+ +| | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_base64("AQEAAAA=")) bts; ``` -### keywords +```text ++------+ +| bts | ++------+ +| 1 | ++------+ +``` - BITMAP_FROM_BASE64,BITMAP +```sql +select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) bts; +``` + +```text ++-----------+ +| bts | ++-----------+ +| 1,9999999 | ++-----------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md index 808b8b34d4295..da4a2e160702c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md @@ -22,42 +22,63 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_string - ## 描述 + +将一个字符串转化为一个 BITMAP,字符串是由逗号分隔的一组 unsigned bigint 数字组成。(数字取值在:0 ~ 18446744073709551615) +比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置。 当输入字段不合法时,返回 NULL + ## 语法 -`BITMAP BITMAP_FROM_STRING(VARCHAR input)` +```sql + BITMAP_FROM_STRING() +``` + +## 参数 + +| 参数 | 说明 | +|---------|---------------------------------------------------| +| `` | 数组字符串,比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置 | -将一个字符串转化为一个BITMAP,字符串是由逗号分隔的一组unsigned bigint数字组成.(数字取值在:0 ~ 18446744073709551615) -比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置. -当输入字段不合法时,返回NULL +## 返回值 + +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 2")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 2")); -+-------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 2')) | -+-------------------------------------------------+ -| 0,1,2 | -+-------------------------------------------------+ - -mysql> select bitmap_from_string("-1, 0, 1, 2"); -+-----------------------------------+ -| bitmap_from_string('-1, 0, 1, 2') | -+-----------------------------------+ -| NULL | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")); -+--------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 18446744073709551615')) | -+--------------------------------------------------------------------+ -| 0,1,18446744073709551615 | -+--------------------------------------------------------------------+ + +```text ++-------+ +| bts | ++-------+ +| 0,1,2 | ++-------+ ``` -### keywords +```sql +select bitmap_from_string("-1, 0, 1, 2") bfs; +``` + +```text ++------+ +| bfs | ++------+ +| NULL | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")) bts; +``` + +```text ++--------------------------+ +| bts | ++--------------------------+ +| 0,1,18446744073709551615 | ++--------------------------+ +``` - BITMAP_FROM_STRING,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md index d1195d50ac5d4..ea8740d957b08 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md @@ -24,54 +24,70 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_count ## 描述 + +计算两个及以上输入 BITMAP 的交集,返回交集的个数. + ## 语法 -`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)` +```sql +BITMAP_AND_COUNT(, ,[, ...]) +``` -计算两个及以上输入bitmap的交集,返回交集的个数. +## 参数 -## 举例 +| 参数 | 说明 | +|------------|------------------| +| `` | 被求交集的原 BITMAP 之一 | -``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_empty()); -+---------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_empty()) | -+---------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------+ +## 返回值 +返回整数 +- 当参数存在空值时,返回 NULL -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3')); -+----------------------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) | -+----------------------------------------------------------------------------+ -| 3 | -+----------------------------------------------------------------------------+ +## 举例 + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +```text +----------------------------------------------------------------------------+ | bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) | +----------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +```text +-------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-------------------------------------------------------------------------------------------------------------+ | 2 | +-------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +-----------------------------------------------------------------------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +``` + +```text +-------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-------------------------------------------------------------------------------------------------------------------+ @@ -79,6 +95,3 @@ MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string(' +-------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - - BITMAP_AND_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md index d815ce04c58a6..5525020465baf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md @@ -24,25 +24,54 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not_count,bitmap_andnot_count ## 描述 + +将两个 BITMAP 进行与非操作并返回计算结果集的元素个数,其中入参第一个叫 `基准 BITMAP`, 第二个叫 `排除 BITMAP`。 + +## 别名 + +- BITMAP_ANDNOT_COUNT + ## 语法 -`BITMAP BITMAP_AND_NOT_COUNT(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND_NOT_COUNT(, ) +``` + +## 参数 + +| 参数 | 说明 | +|-------------|------------------| +| `` | 被求与非的`基准 BITMAP` | +| `` | 被求与非的`排除 BITMAP` | + +## 返回值 -将两个bitmap进行与非操作并返回计算返回的大小. +返回整数。 +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_and_not_count(null, bitmap_from_string('1,2,3')) banc1, bitmap_and_not_count(bitmap_from_string('1,2,3') ,null) banc2; ``` -mysql> select bitmap_and_not_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) cnt; + +```text ++-------+-------+ +| banc1 | banc2 | ++-------+-------+ +| 0 | 0 | ++-------+-------+ +``` + +```sql +select bitmap_and_not_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) banc; +``` + +```text +------+ -| cnt | +| banc | +------+ | 2 | +------+ ``` - -### keywords - - BITMAP_AND_NOT_COUNT,BITMAP_ANDNOT_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md index 5161d373cf4c1..0a2f8306d2870 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md @@ -24,47 +24,78 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not,bitmap_andnot ## 描述 + +将两个 BITMAP 进行与非操作并返回计算结果,其中入参第一个叫 `基准 BITMAP`, 第二个叫 `排除 BITMAP`。 + +## 别名 + +- BITMAP_ANDNOT + ## 语法 -`BITMAP BITMAP_AND_NOT(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND_NOT(, ) +``` + +## 参数 + +| 参数 | 说明 | +|-------------|------------------| +| `` | 被求与非的`基准 BITMAP` | +| `` | 被求与非的`排除 BITMAP` | + +## 返回值 -将两个bitmap进行与非操作并返回计算结果。 +返回一个 BITMAP。 +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; ``` -mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; + +```text +------+ | cnt | +------+ | 2 | +------+ +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +``` + +```text +--------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) | +--------------------------------------------------------------------------------------------+ | 1,2 | +--------------------------------------------------------------------------------------------+ -1 row in set (0.01 sec) +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ; +```text +-------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) | +-------------------------------------------------------------------------------+ | 1,2,3 | +-------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +```text +---------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) | +---------------------------------------------------------------------+ | NULL | +---------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND_NOT,BITMAP_ANDNOT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md index 5a375d519fd43..4773342d152a7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md @@ -24,60 +24,58 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and ## 描述 + +计算两个及以上输入的 BITMAP 的交集,返回新的 BITMAP. + ## 语法 -`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND(, ,[, ...]) +``` + +## 参数 -计算两个及以上输入bitmap的交集,返回新的bitmap. +| 参数 | 说明 | +|------------|------------------| +| `` | 被求交集的原 BITMAP 之一 | + +## 返回值 + +返回一个 BITMAP +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); ``` -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) | -+----------------------------------------------------------+ -| | -+----------------------------------------------------------+ - -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ - -MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ - -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); + +```text +-----------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-----------------------------------------------------------------------------------------------------------------------+ | 1,2 | +-----------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +```text +---------------------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +---------------------------------------------------------------------------------------------------------------------------------------+ | | +---------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-----------------------------------------------------------------------------------------------------------------------------+ @@ -85,6 +83,4 @@ MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_fr +-----------------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - BITMAP_AND,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md index 459fe27f792c2..9a2e978bbbddf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md @@ -24,32 +24,39 @@ specific language governing permissions and limitations under the License. --> -## bitmap_contains ## 描述 + +计算输入值是否在 BITMAP 中,返回值是 boolean 值. + ## 语法 -`BOOLEAN BITMAP_CONTAINS(BITMAP bitmap, BIGINT input)` +```sql +BITMAP_CONTAINS(, ) +``` + +## 参数 -计算输入值是否在Bitmap列中,返回值是Boolean值. +| 参数 | 说明 | +|------------|------------| +| `` | BITMAP 集合 | +| `` | 被判断是否存在的整数 | + +## 返回值 + +返回一个 boolean +- 当参数存在空时,返回 NULL ## 举例 -``` -mysql> select bitmap_contains(to_bitmap(1),2) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_contains(to_bitmap(1),1) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ +```sql +select bitmap_contains(to_bitmap(1),2) cnt1, bitmap_contains(to_bitmap(1),1) cnt2; ``` -### keywords +```text ++------+------+ +| cnt1 | cnt2 | ++------+------+ +| 0 | 1 | ++------+------+ +``` - BITMAP_CONTAINS,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md index 6ac20407e0a7e..e8c74a86b7dd0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md @@ -24,33 +24,36 @@ specific language governing permissions and limitations under the License. --> -## bitmap_count ## 描述 + +计算输入 BITMAP 的元素个数 + ## 语法 -`BITMAP BITMAP_COUNT(BITMAP lhs)` +```sql +BITMAP_COUNT() +``` + +## 参数 -返回输入bitmap的个数。 +| 参数 | 说明 | +|------------|------------| +| `` | BITMAP 集合 | + +## 返回值 + +返回一个整数 ## 举例 +```sql +select bitmap_count(to_bitmap(1)) cnt; ``` -mysql> select bitmap_count(to_bitmap(1)) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; +```text +------+ | cnt | +------+ | 1 | +------+ - ``` - -### keywords - - BITMAP_COUNT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md index c692447e84a55..7f9141c3ef18e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md @@ -24,37 +24,46 @@ specific language governing permissions and limitations under the License. --> -## bitmap_empty ## 描述 -## 语法 - -`BITMAP BITMAP_EMPTY()` -返回一个空bitmap。主要用于 insert 或 stream load 时填充默认值。例如 +构建一个空 BITMAP。主要用于 insert 或 stream load 时填充默认值。例如: ``` -cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://host:8410/api/test/testDb/_stream_load +cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://127.0.0.1:8040/api/test_database/test_table/_stream_load +``` + +## 语法 + +```sql +BITMAP_EMPTY() ``` +## 返回值 + +返回一个无元素的空 BITMAP。 + ## 举例 +```sql +select bitmap_to_string(bitmap_empty()); ``` -mysql> select bitmap_count(bitmap_empty()); -+------------------------------+ -| bitmap_count(bitmap_empty()) | -+------------------------------+ -| 0 | -+------------------------------+ -mysql> select bitmap_to_string(bitmap_empty()); +```text +----------------------------------+ | bitmap_to_string(bitmap_empty()) | +----------------------------------+ | | +----------------------------------+ - ``` -### keywords +```sql +select bitmap_count(bitmap_empty()); +``` - BITMAP_EMPTY,BITMAP +```text ++------------------------------+ +| bitmap_count(bitmap_empty()) | ++------------------------------+ +| 0 | ++------------------------------+ +``` \ 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/bitmap-functions/bitmap-from-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md index 7efe53b77f919..04935baafaa67 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md @@ -22,32 +22,38 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_array - ## 描述 + +将一个 TINYINT/SMALLINT/INT/BIGINT 类型的数组转化为一个 BITMAP,当输入字段不合法时,结果返回 NULL + ## 语法 -`BITMAP BITMAP_FROM_ARRAY(ARRAY input)` +```sql +BITMAP_FROM_ARRAY() +``` + +## 参数 -将一个TINYINT/SMALLINT/INT/BIGINT类型的数组转化为一个BITMAP -当输入字段不合法时,结果返回NULL +| 参数 | 说明 | +|---------|------| +| `` | 整形数组 | + +## 返回值 + +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 -``` -mysql> select *, bitmap_to_string(bitmap_from_array(c_array)) from array_test; -+------+-----------------------+------------------------------------------------+ -| id | c_array | bitmap_to_string(bitmap_from_array(`c_array`)) | -+------+-----------------------+------------------------------------------------+ -| 1 | [NULL] | NULL | -| 2 | [1, 2, 3, NULL] | NULL | -| 2 | [1, 2, 3, -10] | NULL | -| 3 | [1, 2, 3, 4, 5, 6, 7] | 1,2,3,4,5,6,7 | -| 4 | [100, 200, 300, 300] | 100,200,300 | -+------+-----------------------+------------------------------------------------+ -5 rows in set (0.02 sec) +```sql +SELECT bitmap_to_string(bitmap_from_array(array(1, 0, 1, 1, 0, 1, 0))) AS bs; ``` -### keywords +```text ++------+ +| bs | ++------+ +| 0,1 | ++------+ +``` - BITMAP_FROM_ARRAY,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md index 2a372f1cdb246..3ed2126d32a5b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md @@ -22,40 +22,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_base64 - ## 描述 + +将一个 base64 字符串(可以由 `bitmap_to_base64` 函数转换来)转化为一个 BITMAP。当输入字符串不合法时,返回 NULL。 + ## 语法 -`BITMAP BITMAP_FROM_BASE64(VARCHAR input)` +```sql + BITMAP_FROM_BASE64() +``` + +## 参数 + +| 参数 | 说明 | +|----------------|----------------------------------------| +| `` | base64 字符串(可以由`bitmap_to_base64`函数转换来) | + +## 返回值 -将一个base64字符串(`bitmap_to_base64`函数的结果)转化为一个BITMAP。当输入字符串不合法时,返回NULL。 +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_from_base64("AA==")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_base64("AA==")); -+----------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AA==")) | -+----------------------------------------------+ -| | -+----------------------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AQEAAAA=")); -+-----------------------------------+ -| bitmap_to_string(bitmap_from_base64("AQEAAAA=")) | -+-----------------------------------+ -| 1 | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")); -+----------------------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) | -+----------------------------------------------------------------------------------+ -| 1,9999999 | -+----------------------------------------------------------------------------------+ + +```text ++------+ +| bts | ++------+ +| | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_base64("AQEAAAA=")) bts; ``` -### keywords +```text ++------+ +| bts | ++------+ +| 1 | ++------+ +``` - BITMAP_FROM_BASE64,BITMAP +```sql +select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) bts; +``` + +```text ++-----------+ +| bts | ++-----------+ +| 1,9999999 | ++-----------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md index 808b8b34d4295..da4a2e160702c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md @@ -22,42 +22,63 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_string - ## 描述 + +将一个字符串转化为一个 BITMAP,字符串是由逗号分隔的一组 unsigned bigint 数字组成。(数字取值在:0 ~ 18446744073709551615) +比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置。 当输入字段不合法时,返回 NULL + ## 语法 -`BITMAP BITMAP_FROM_STRING(VARCHAR input)` +```sql + BITMAP_FROM_STRING() +``` + +## 参数 + +| 参数 | 说明 | +|---------|---------------------------------------------------| +| `` | 数组字符串,比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置 | -将一个字符串转化为一个BITMAP,字符串是由逗号分隔的一组unsigned bigint数字组成.(数字取值在:0 ~ 18446744073709551615) -比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置. -当输入字段不合法时,返回NULL +## 返回值 + +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 2")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 2")); -+-------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 2')) | -+-------------------------------------------------+ -| 0,1,2 | -+-------------------------------------------------+ - -mysql> select bitmap_from_string("-1, 0, 1, 2"); -+-----------------------------------+ -| bitmap_from_string('-1, 0, 1, 2') | -+-----------------------------------+ -| NULL | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")); -+--------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 18446744073709551615')) | -+--------------------------------------------------------------------+ -| 0,1,18446744073709551615 | -+--------------------------------------------------------------------+ + +```text ++-------+ +| bts | ++-------+ +| 0,1,2 | ++-------+ ``` -### keywords +```sql +select bitmap_from_string("-1, 0, 1, 2") bfs; +``` + +```text ++------+ +| bfs | ++------+ +| NULL | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")) bts; +``` + +```text ++--------------------------+ +| bts | ++--------------------------+ +| 0,1,18446744073709551615 | ++--------------------------+ +``` - BITMAP_FROM_STRING,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md index d1195d50ac5d4..ea8740d957b08 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md @@ -24,54 +24,70 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_count ## 描述 + +计算两个及以上输入 BITMAP 的交集,返回交集的个数. + ## 语法 -`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)` +```sql +BITMAP_AND_COUNT(, ,[, ...]) +``` -计算两个及以上输入bitmap的交集,返回交集的个数. +## 参数 -## 举例 +| 参数 | 说明 | +|------------|------------------| +| `` | 被求交集的原 BITMAP 之一 | -``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_empty()); -+---------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_empty()) | -+---------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------+ +## 返回值 +返回整数 +- 当参数存在空值时,返回 NULL -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3')); -+----------------------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) | -+----------------------------------------------------------------------------+ -| 3 | -+----------------------------------------------------------------------------+ +## 举例 + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +```text +----------------------------------------------------------------------------+ | bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) | +----------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +```text +-------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-------------------------------------------------------------------------------------------------------------+ | 2 | +-------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +-----------------------------------------------------------------------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +``` + +```text +-------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-------------------------------------------------------------------------------------------------------------------+ @@ -79,6 +95,3 @@ MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string(' +-------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - - BITMAP_AND_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md index d815ce04c58a6..5525020465baf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md @@ -24,25 +24,54 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not_count,bitmap_andnot_count ## 描述 + +将两个 BITMAP 进行与非操作并返回计算结果集的元素个数,其中入参第一个叫 `基准 BITMAP`, 第二个叫 `排除 BITMAP`。 + +## 别名 + +- BITMAP_ANDNOT_COUNT + ## 语法 -`BITMAP BITMAP_AND_NOT_COUNT(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND_NOT_COUNT(, ) +``` + +## 参数 + +| 参数 | 说明 | +|-------------|------------------| +| `` | 被求与非的`基准 BITMAP` | +| `` | 被求与非的`排除 BITMAP` | + +## 返回值 -将两个bitmap进行与非操作并返回计算返回的大小. +返回整数。 +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_and_not_count(null, bitmap_from_string('1,2,3')) banc1, bitmap_and_not_count(bitmap_from_string('1,2,3') ,null) banc2; ``` -mysql> select bitmap_and_not_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) cnt; + +```text ++-------+-------+ +| banc1 | banc2 | ++-------+-------+ +| 0 | 0 | ++-------+-------+ +``` + +```sql +select bitmap_and_not_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) banc; +``` + +```text +------+ -| cnt | +| banc | +------+ | 2 | +------+ ``` - -### keywords - - BITMAP_AND_NOT_COUNT,BITMAP_ANDNOT_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md index 5161d373cf4c1..0a2f8306d2870 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md @@ -24,47 +24,78 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not,bitmap_andnot ## 描述 + +将两个 BITMAP 进行与非操作并返回计算结果,其中入参第一个叫 `基准 BITMAP`, 第二个叫 `排除 BITMAP`。 + +## 别名 + +- BITMAP_ANDNOT + ## 语法 -`BITMAP BITMAP_AND_NOT(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND_NOT(, ) +``` + +## 参数 + +| 参数 | 说明 | +|-------------|------------------| +| `` | 被求与非的`基准 BITMAP` | +| `` | 被求与非的`排除 BITMAP` | + +## 返回值 -将两个bitmap进行与非操作并返回计算结果。 +返回一个 BITMAP。 +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; ``` -mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; + +```text +------+ | cnt | +------+ | 2 | +------+ +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +``` + +```text +--------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) | +--------------------------------------------------------------------------------------------+ | 1,2 | +--------------------------------------------------------------------------------------------+ -1 row in set (0.01 sec) +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ; +```text +-------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) | +-------------------------------------------------------------------------------+ | 1,2,3 | +-------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +```text +---------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) | +---------------------------------------------------------------------+ | NULL | +---------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND_NOT,BITMAP_ANDNOT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md index 5a375d519fd43..4773342d152a7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md @@ -24,60 +24,58 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and ## 描述 + +计算两个及以上输入的 BITMAP 的交集,返回新的 BITMAP. + ## 语法 -`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs)` +```sql +BITMAP_AND(, ,[, ...]) +``` + +## 参数 -计算两个及以上输入bitmap的交集,返回新的bitmap. +| 参数 | 说明 | +|------------|------------------| +| `` | 被求交集的原 BITMAP 之一 | + +## 返回值 + +返回一个 BITMAP +- 当参数存在空值时,返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); ``` -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) | -+----------------------------------------------------------+ -| | -+----------------------------------------------------------+ - -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ - -MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ - -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); + +```text +-----------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-----------------------------------------------------------------------------------------------------------------------+ | 1,2 | +-----------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +```text +---------------------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +---------------------------------------------------------------------------------------------------------------------------------------+ | | +---------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-----------------------------------------------------------------------------------------------------------------------------+ @@ -85,6 +83,4 @@ MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_fr +-----------------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - BITMAP_AND,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md index 459fe27f792c2..9a2e978bbbddf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md @@ -24,32 +24,39 @@ specific language governing permissions and limitations under the License. --> -## bitmap_contains ## 描述 + +计算输入值是否在 BITMAP 中,返回值是 boolean 值. + ## 语法 -`BOOLEAN BITMAP_CONTAINS(BITMAP bitmap, BIGINT input)` +```sql +BITMAP_CONTAINS(, ) +``` + +## 参数 -计算输入值是否在Bitmap列中,返回值是Boolean值. +| 参数 | 说明 | +|------------|------------| +| `` | BITMAP 集合 | +| `` | 被判断是否存在的整数 | + +## 返回值 + +返回一个 boolean +- 当参数存在空时,返回 NULL ## 举例 -``` -mysql> select bitmap_contains(to_bitmap(1),2) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_contains(to_bitmap(1),1) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ +```sql +select bitmap_contains(to_bitmap(1),2) cnt1, bitmap_contains(to_bitmap(1),1) cnt2; ``` -### keywords +```text ++------+------+ +| cnt1 | cnt2 | ++------+------+ +| 0 | 1 | ++------+------+ +``` - BITMAP_CONTAINS,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md index 6ac20407e0a7e..e8c74a86b7dd0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md @@ -24,33 +24,36 @@ specific language governing permissions and limitations under the License. --> -## bitmap_count ## 描述 + +计算输入 BITMAP 的元素个数 + ## 语法 -`BITMAP BITMAP_COUNT(BITMAP lhs)` +```sql +BITMAP_COUNT() +``` + +## 参数 -返回输入bitmap的个数。 +| 参数 | 说明 | +|------------|------------| +| `` | BITMAP 集合 | + +## 返回值 + +返回一个整数 ## 举例 +```sql +select bitmap_count(to_bitmap(1)) cnt; ``` -mysql> select bitmap_count(to_bitmap(1)) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; +```text +------+ | cnt | +------+ | 1 | +------+ - ``` - -### keywords - - BITMAP_COUNT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md index c692447e84a55..7f9141c3ef18e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md @@ -24,37 +24,46 @@ specific language governing permissions and limitations under the License. --> -## bitmap_empty ## 描述 -## 语法 - -`BITMAP BITMAP_EMPTY()` -返回一个空bitmap。主要用于 insert 或 stream load 时填充默认值。例如 +构建一个空 BITMAP。主要用于 insert 或 stream load 时填充默认值。例如: ``` -cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://host:8410/api/test/testDb/_stream_load +cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://127.0.0.1:8040/api/test_database/test_table/_stream_load +``` + +## 语法 + +```sql +BITMAP_EMPTY() ``` +## 返回值 + +返回一个无元素的空 BITMAP。 + ## 举例 +```sql +select bitmap_to_string(bitmap_empty()); ``` -mysql> select bitmap_count(bitmap_empty()); -+------------------------------+ -| bitmap_count(bitmap_empty()) | -+------------------------------+ -| 0 | -+------------------------------+ -mysql> select bitmap_to_string(bitmap_empty()); +```text +----------------------------------+ | bitmap_to_string(bitmap_empty()) | +----------------------------------+ | | +----------------------------------+ - ``` -### keywords +```sql +select bitmap_count(bitmap_empty()); +``` - BITMAP_EMPTY,BITMAP +```text ++------------------------------+ +| bitmap_count(bitmap_empty()) | ++------------------------------+ +| 0 | ++------------------------------+ +``` \ 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/bitmap-functions/bitmap-from-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md index 7efe53b77f919..04935baafaa67 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md @@ -22,32 +22,38 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_array - ## 描述 + +将一个 TINYINT/SMALLINT/INT/BIGINT 类型的数组转化为一个 BITMAP,当输入字段不合法时,结果返回 NULL + ## 语法 -`BITMAP BITMAP_FROM_ARRAY(ARRAY input)` +```sql +BITMAP_FROM_ARRAY() +``` + +## 参数 -将一个TINYINT/SMALLINT/INT/BIGINT类型的数组转化为一个BITMAP -当输入字段不合法时,结果返回NULL +| 参数 | 说明 | +|---------|------| +| `` | 整形数组 | + +## 返回值 + +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 -``` -mysql> select *, bitmap_to_string(bitmap_from_array(c_array)) from array_test; -+------+-----------------------+------------------------------------------------+ -| id | c_array | bitmap_to_string(bitmap_from_array(`c_array`)) | -+------+-----------------------+------------------------------------------------+ -| 1 | [NULL] | NULL | -| 2 | [1, 2, 3, NULL] | NULL | -| 2 | [1, 2, 3, -10] | NULL | -| 3 | [1, 2, 3, 4, 5, 6, 7] | 1,2,3,4,5,6,7 | -| 4 | [100, 200, 300, 300] | 100,200,300 | -+------+-----------------------+------------------------------------------------+ -5 rows in set (0.02 sec) +```sql +SELECT bitmap_to_string(bitmap_from_array(array(1, 0, 1, 1, 0, 1, 0))) AS bs; ``` -### keywords +```text ++------+ +| bs | ++------+ +| 0,1 | ++------+ +``` - BITMAP_FROM_ARRAY,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md index 2a372f1cdb246..3ed2126d32a5b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md @@ -22,40 +22,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_base64 - ## 描述 + +将一个 base64 字符串(可以由 `bitmap_to_base64` 函数转换来)转化为一个 BITMAP。当输入字符串不合法时,返回 NULL。 + ## 语法 -`BITMAP BITMAP_FROM_BASE64(VARCHAR input)` +```sql + BITMAP_FROM_BASE64() +``` + +## 参数 + +| 参数 | 说明 | +|----------------|----------------------------------------| +| `` | base64 字符串(可以由`bitmap_to_base64`函数转换来) | + +## 返回值 -将一个base64字符串(`bitmap_to_base64`函数的结果)转化为一个BITMAP。当输入字符串不合法时,返回NULL。 +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_from_base64("AA==")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_base64("AA==")); -+----------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AA==")) | -+----------------------------------------------+ -| | -+----------------------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AQEAAAA=")); -+-----------------------------------+ -| bitmap_to_string(bitmap_from_base64("AQEAAAA=")) | -+-----------------------------------+ -| 1 | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")); -+----------------------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) | -+----------------------------------------------------------------------------------+ -| 1,9999999 | -+----------------------------------------------------------------------------------+ + +```text ++------+ +| bts | ++------+ +| | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_base64("AQEAAAA=")) bts; ``` -### keywords +```text ++------+ +| bts | ++------+ +| 1 | ++------+ +``` - BITMAP_FROM_BASE64,BITMAP +```sql +select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) bts; +``` + +```text ++-----------+ +| bts | ++-----------+ +| 1,9999999 | ++-----------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md index 808b8b34d4295..da4a2e160702c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md @@ -22,42 +22,63 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_string - ## 描述 + +将一个字符串转化为一个 BITMAP,字符串是由逗号分隔的一组 unsigned bigint 数字组成。(数字取值在:0 ~ 18446744073709551615) +比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置。 当输入字段不合法时,返回 NULL + ## 语法 -`BITMAP BITMAP_FROM_STRING(VARCHAR input)` +```sql + BITMAP_FROM_STRING() +``` + +## 参数 + +| 参数 | 说明 | +|---------|---------------------------------------------------| +| `` | 数组字符串,比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置 | -将一个字符串转化为一个BITMAP,字符串是由逗号分隔的一组unsigned bigint数字组成.(数字取值在:0 ~ 18446744073709551615) -比如"0, 1, 2"字符串会转化为一个Bitmap,其中的第0, 1, 2位被设置. -当输入字段不合法时,返回NULL +## 返回值 + +返回一个 BITMAP +- 当输入字段不合法时,结果返回 NULL ## 举例 +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 2")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 2")); -+-------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 2')) | -+-------------------------------------------------+ -| 0,1,2 | -+-------------------------------------------------+ - -mysql> select bitmap_from_string("-1, 0, 1, 2"); -+-----------------------------------+ -| bitmap_from_string('-1, 0, 1, 2') | -+-----------------------------------+ -| NULL | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")); -+--------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 18446744073709551615')) | -+--------------------------------------------------------------------+ -| 0,1,18446744073709551615 | -+--------------------------------------------------------------------+ + +```text ++-------+ +| bts | ++-------+ +| 0,1,2 | ++-------+ ``` -### keywords +```sql +select bitmap_from_string("-1, 0, 1, 2") bfs; +``` + +```text ++------+ +| bfs | ++------+ +| NULL | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")) bts; +``` + +```text ++--------------------------+ +| bts | ++--------------------------+ +| 0,1,18446744073709551615 | ++--------------------------+ +``` - BITMAP_FROM_STRING,BITMAP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md index 14991554520dc..840f9bb600430 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md @@ -24,54 +24,70 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_count -### description -#### Syntax +## Description -`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)` +Computes the intersection of two or more input BITMAPs and returns the number of intersections. -Calculate the intersection of two or more input bitmaps and return the number of intersections. - -### example +## Syntax +```sql +BITMAP_AND_COUNT(, ,[, ...]) ``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_empty()); -+---------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_empty()) | -+---------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------+ +## Parameters -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3')); -+----------------------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) | -+----------------------------------------------------------------------------+ -| 3 | -+----------------------------------------------------------------------------+ +| Parameter | Description | +|------------|----------------------------------------------------------------| +| `` | One of the original BITMAPs whose intersection is being sought | + +## Return Value -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +Returns an integer +- If the parameter has a null value, it returns NULL + +## Examples + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +``` + +```text +----------------------------------------------------------------------------+ | bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) | +----------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------+ +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +``` + +```text +-------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-------------------------------------------------------------------------------------------------------------+ | 2 | +-------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +-----------------------------------------------------------------------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +```text +-------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-------------------------------------------------------------------------------------------------------------------+ @@ -79,6 +95,3 @@ MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string(' +-------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - - BITMAP_AND_COUNT,BITMAP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md index 11695a9e4e2b0..1e3e563b62884 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md @@ -24,26 +24,54 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not_count,bitmap_andnot_count -### description -#### Syntax +## Description -`BITMAP BITMAP_AND_NOT_COUNT(BITMAP lhs, BITMAP rhs)` +Performs a NOT operation on two BITMAPs and returns the number of elements in the result set. The first input parameter is called `base BITMAP` and the second is called `exclusion BITMAP`. -Calculate the set after lhs minus intersection of two input bitmaps, return the new bitmap size. +## Alias +- BITMAP_ANDNOT_COUNT -### example +## Syntax +```sql +BITMAP_AND_NOT_COUNT(, ) ``` -mysql> select bitmap_and_not_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) cnt; + +## Parameters + +| Parameter | Description | +|-------------|----------------------------------| +| `` | `Base BITMAP` to be negated | +| `` | `Exclusion BITMAP` to be negated | + +## Return Value + +Returns an integer. +- If the parameter has a null value, returns NULL + +## Examples + +```sql +select bitmap_and_not_count(null, bitmap_from_string('1,2,3')) banc1, bitmap_and_not_count(bitmap_from_string('1,2,3') ,null) banc2; +``` + +```text ++-------+-------+ +| banc1 | banc2 | ++-------+-------+ +| 0 | 0 | ++-------+-------+ +``` + +```sql +select bitmap_and_not_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) banc; +``` + +```text +------+ -| cnt | +| banc | +------+ | 2 | +------+ -``` - -### keywords - - BITMAP_AND_NOT_COUNT,BITMAP_ANDNOT_COUNT,BITMAP +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md index beee61656dcce..b7abb3e6d964d 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md @@ -24,46 +24,78 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not,bitmap_andnot -### description -#### Syntax +## Description -`BITMAP BITMAP_AND_NOT(BITMAP lhs, BITMAP rhs)` +Perform a NOT operation on two BITMAPs and return the result. The first input parameter is called `base BITMAP` and the second is called `exclude BITMAP`. -Calculate the set after lhs minus intersection of two input bitmaps, return the new bitmap. +## Alias -### example +- BITMAP_ANDNOT +## Syntax + +```sql +BITMAP_AND_NOT(, ) +``` + +## Parameters + +| Parameter | Description | +|-------------|----------------------------------| +| `` | `Base BITMAP` to be negated | +| `` | `Exclusion BITMAP` to be negated | + +## Return Value + +Returns a BITMAP. +- If the parameter has a null value, returns NULL + +## Examples + +```sql +select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; ``` -mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; + +```text +------+ | cnt | +------+ | 2 | +------+ +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +``` + +```text +--------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) | +--------------------------------------------------------------------------------------------+ | 1,2 | +--------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ; +```text +-------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) | +-------------------------------------------------------------------------------+ | 1,2,3 | +-------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +```text +---------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) | +---------------------------------------------------------------------+ | NULL | +---------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND_NOT,BITMAP_ANDNOT,BITMAP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md index b638a31dcd55d..99630843af578 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md @@ -24,67 +24,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and -### description -#### Syntax +## Description -`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs, ...)` +Computes the intersection of two or more input BITMAPs and returns a new BITMAP. -Compute intersection of two or more input bitmaps, return the new bitmap. +## Syntax -### example +```sql +BITMAP_AND(, ,[, ...]) +``` + +## Parameters + +| Parameter | Description | +|------------|----------------------------------------------------------------| +| `` | One of the original BITMAPs whose intersection is being sought | + +## Return Value +Returns a BITMAP +- If the parameter has a null value, it returns NULL + +## Examples + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); ``` -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) | -+----------------------------------------------------------+ -| | -+----------------------------------------------------------+ - -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ - -MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ - -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); + +```text +-----------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-----------------------------------------------------------------------------------------------------------------------+ | 1,2 | +-----------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +``` + +```text +---------------------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +---------------------------------------------------------------------------------------------------------------------------------------+ | | +---------------------------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-----------------------------------------------------------------------------------------------------------------------------+ | NULL | +-----------------------------------------------------------------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND,BITMAP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md index 01b8e665cb320..4cf5f7fd04140 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md @@ -24,32 +24,39 @@ specific language governing permissions and limitations under the License. --> -## bitmap_contains -### description -#### Syntax +## Description -`BOOLEAN BITMAP_CONTAINS(BITMAP bitmap, BIGINT input)` +Calculates whether the input value is in the BITMAP and returns a boolean value. -Calculates whether the input value is in the Bitmap column and returns a Boolean value. - -### example +## Syntax +```sql +BITMAP_CONTAINS(, ) ``` -mysql> select bitmap_contains(to_bitmap(1),2) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_contains(to_bitmap(1),1) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ + +## Parameters + +| Parameter | Description | +|------------|-----------------------------------------| +| `` | BITMAP collection | +| `` | The integer to be checked for existence | + +## Return Value + +Returns a boolean +- If the parameter is empty, returns NULL + +## Examples + +```sql +select bitmap_contains(to_bitmap(1),2) cnt1, bitmap_contains(to_bitmap(1),1) cnt2; ``` -### keywords +```text ++------+------+ +| cnt1 | cnt2 | ++------+------+ +| 0 | 1 | ++------+------+ +``` - BITMAP_CONTAINS,BITMAP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md index fb90c995890e5..ccb9e3f66b083 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md @@ -24,33 +24,37 @@ specific language governing permissions and limitations under the License. --> -## bitmap_count -### description -#### Syntax +## Description -`BITMAP BITMAP_COUNT(BITMAP lhs)` +Count the number of elements in the input BITMAP -Returns the number of input bitmaps. +## Syntax -### example +```sql +BITMAP_COUNT() +``` + +## Parameters + +| Parameter | Description | +|------------|-------------| +| `` | a BITMAP | + +## Return Value +Returns an integer + +## Examples + +```sql +select bitmap_count(to_bitmap(1)) cnt; ``` -mysql> select bitmap_count(to_bitmap(1)) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; +```text +------+ | cnt | +------+ | 1 | +------+ - ``` -### keywords - - BITMAP_COUNT diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md index 291f926ec2195..429dcfc945e76 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md @@ -24,29 +24,31 @@ specific language governing permissions and limitations under the License. --> -## bitmap_empty -### description -#### Syntax +## Description -`BITMAP BITMAP_EMPTY()` - -Return an empty bitmap. Mainly be used to supply default value for bitmap column when loading, e.g., +Construct an empty BITMAP. Mainly used to fill default values during insert or stream load. For example: ``` -cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://host:8410/api/test/testDb/_stream_load +cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://127.0.0.1:8040/api/test_database/test_table/_stream_load ``` -### example +## Syntax +```sql +BITMAP_EMPTY() ``` -mysql> select bitmap_count(bitmap_empty()); -+------------------------------+ -| bitmap_count(bitmap_empty()) | -+------------------------------+ -| 0 | -+------------------------------+ -mysql> select bitmap_to_string(bitmap_empty()); +## Return Value + +Returns an empty array with no elements + +## Examples + +```sql +select bitmap_to_string(bitmap_empty()); +``` + +```text +----------------------------------+ | bitmap_to_string(bitmap_empty()) | +----------------------------------+ @@ -54,6 +56,14 @@ mysql> select bitmap_to_string(bitmap_empty()); +----------------------------------+ ``` -### keywords +```sql +select bitmap_count(bitmap_empty()); +``` - BITMAP_EMPTY,BITMAP +```text ++------------------------------+ +| bitmap_count(bitmap_empty()) | ++------------------------------+ +| 0 | ++------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md index 6ba524d46733c..dda3105a861ff 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md @@ -22,32 +22,37 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_array +## Description -### description -#### Syntax +Converts an array of TINYINT/SMALLINT/INT/BIGINT type to a BITMAP. When the input field is illegal, the result returns NULL. -`BITMAP BITMAP_FROM_ARRAY(ARRAY input)` +## Syntax -Convert a TINYINT/SMALLINT/INT/BIGINT array to a BITMAP -When the input field is illegal, the result returns NULL +```sql +BITMAP_FROM_ARRAY() +``` -### example +## Parameters -``` -mysql> select *, bitmap_to_string(bitmap_from_array(c_array)) from array_test; -+------+-----------------------+------------------------------------------------+ -| id | c_array | bitmap_to_string(bitmap_from_array(`c_array`)) | -+------+-----------------------+------------------------------------------------+ -| 1 | [NULL] | NULL | -| 2 | [1, 2, 3, NULL] | NULL | -| 2 | [1, 2, 3, -10] | NULL | -| 3 | [1, 2, 3, 4, 5, 6, 7] | 1,2,3,4,5,6,7 | -| 4 | [100, 200, 300, 300] | 100,200,300 | -+------+-----------------------+------------------------------------------------+ -5 rows in set (0.02 sec) -``` +| Parameter | Description | +|-----------|---------------| +| `` | integer array | + +## Return Value -### keywords +Returns a BITMAP +- When the input field is invalid, the result is NULL + +## Examples + +```sql +SELECT bitmap_to_string(bitmap_from_array(array(1, 0, 1, 1, 0, 1, 0))) AS bs; +``` - BITMAP_FROM_ARRAY,BITMAP +```text ++------+ +| bs | ++------+ +| 0,1 | ++------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md index 4a60f9e5fc9d0..5c2278edff910 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md @@ -22,40 +22,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_base64 +## Description -### description -#### Syntax +Convert a base64 string (which can be converted by `bitmap_to_base64` function) to a BITMAP. Returns NULL when the input string is invalid. -`BITMAP BITMAP_FROM_BASE64(VARCHAR input)` +## Syntax -Convert a base64 string(result of function `bitmap_to_base64`) into a bitmap. If input string is invalid, return NULL. +```sql + BITMAP_FROM_BASE64() +``` + +## Parameters + +| Parameter | Description | +|----------------|-----------------------------------------------------------------| +| `` | base64 string (can be converted by `bitmap_to_base64` function) | + +## Return Value + +Returns a BITMAP +- When the input field is invalid, the result is NULL + +## Examples -### example +```sql +select bitmap_to_string(bitmap_from_base64("AA==")) bts; +``` + +```text ++------+ +| bts | ++------+ +| | ++------+ +``` +```sql +select bitmap_to_string(bitmap_from_base64("AQEAAAA=")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_base64("AA==")); -+----------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AA==")) | -+----------------------------------------------+ -| | -+----------------------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AQEAAAA=")); -+-----------------------------------+ -| bitmap_to_string(bitmap_from_base64("AQEAAAA=")) | -+-----------------------------------+ -| 1 | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")); -+----------------------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) | -+----------------------------------------------------------------------------------+ -| 1,9999999 | -+----------------------------------------------------------------------------------+ + +```text ++------+ +| bts | ++------+ +| 1 | ++------+ ``` -### keywords +```sql +select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) bts; +``` - BITMAP_FROM_BASE64,BITMAP +```text ++-----------+ +| bts | ++-----------+ +| 1,9999999 | ++-----------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md index 672306960b0b4..e835d895d9075 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md @@ -22,42 +22,63 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_string +## Description -### description -#### Syntax +Convert a string into a BITMAP. The string consists of a group of unsigned bigint numbers separated by commas. (The number values are between: 0 ~ 18446744073709551615) +For example, the string "0, 1, 2" will be converted into a Bitmap, where the 0th, 1st, and 2nd bits are set. When the input field is invalid, NULL is returned -`BITMAP BITMAP_FROM_STRING(VARCHAR input)` +## Syntax -Convert a string into a bitmap. The input string should be a comma separated unsigned bigint (ranging from 0 to 18446744073709551615). -For example: input string "0, 1, 2" will be converted to a Bitmap with bit 0, 1, 2 set. -If input string is invalid, return NULL. +```sql + BITMAP_FROM_STRING() +``` + +## Parameters + +| Parameter | Description | +|-----------|------------------------------------------------------------------------------------------------| +| `` | Array string, for example "0, 1, 2" string will be converted to a Bitmap with bits 0, 1, 2 set | + +## Return Value -### example +Returns a BITMAP +- When the input field is invalid, the result is NULL +## Examples + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 2")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 2")); -+-------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 2')) | -+-------------------------------------------------+ -| 0,1,2 | -+-------------------------------------------------+ - -mysql> select bitmap_from_string("-1, 0, 1, 2"); -+-----------------------------------+ -| bitmap_from_string('-1, 0, 1, 2') | -+-----------------------------------+ -| NULL | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")); -+--------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 18446744073709551615')) | -+--------------------------------------------------------------------+ -| 0,1,18446744073709551615 | -+--------------------------------------------------------------------+ + +```text ++-------+ +| bts | ++-------+ +| 0,1,2 | ++-------+ ``` -### keywords +```sql +select bitmap_from_string("-1, 0, 1, 2") bfs; +``` + +```text ++------+ +| bfs | ++------+ +| NULL | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")) bts; +``` + +```text ++--------------------------+ +| bts | ++--------------------------+ +| 0,1,18446744073709551615 | ++--------------------------+ +``` - BITMAP_FROM_STRING,BITMAP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md index 14991554520dc..840f9bb600430 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-count.md @@ -24,54 +24,70 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_count -### description -#### Syntax +## Description -`BigIntVal bitmap_and_count(BITMAP lhs, BITMAP rhs, ...)` +Computes the intersection of two or more input BITMAPs and returns the number of intersections. -Calculate the intersection of two or more input bitmaps and return the number of intersections. - -### example +## Syntax +```sql +BITMAP_AND_COUNT(, ,[, ...]) ``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_empty()); -+---------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_empty()) | -+---------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------+ +## Parameters -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3')); -+----------------------------------------------------------------------------+ -| bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2,3')) | -+----------------------------------------------------------------------------+ -| 3 | -+----------------------------------------------------------------------------+ +| Parameter | Description | +|------------|----------------------------------------------------------------| +| `` | One of the original BITMAPs whose intersection is being sought | + +## Return Value -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +Returns an integer +- If the parameter has a null value, it returns NULL + +## Examples + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')); +``` + +```text +----------------------------------------------------------------------------+ | bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) | +----------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------+ +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5')); +``` + +```text +-------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-------------------------------------------------------------------------------------------------------------+ | 2 | +-------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty()); +```text +-----------------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +-----------------------------------------------------------------------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +``` -MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL); +```text +-------------------------------------------------------------------------------------------------------------------+ | (bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-------------------------------------------------------------------------------------------------------------------+ @@ -79,6 +95,3 @@ MySQL> select bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string(' +-------------------------------------------------------------------------------------------------------------------+ ``` -### keywords - - BITMAP_AND_COUNT,BITMAP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md index 11695a9e4e2b0..1e3e563b62884 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not-count.md @@ -24,26 +24,54 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not_count,bitmap_andnot_count -### description -#### Syntax +## Description -`BITMAP BITMAP_AND_NOT_COUNT(BITMAP lhs, BITMAP rhs)` +Performs a NOT operation on two BITMAPs and returns the number of elements in the result set. The first input parameter is called `base BITMAP` and the second is called `exclusion BITMAP`. -Calculate the set after lhs minus intersection of two input bitmaps, return the new bitmap size. +## Alias +- BITMAP_ANDNOT_COUNT -### example +## Syntax +```sql +BITMAP_AND_NOT_COUNT(, ) ``` -mysql> select bitmap_and_not_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) cnt; + +## Parameters + +| Parameter | Description | +|-------------|----------------------------------| +| `` | `Base BITMAP` to be negated | +| `` | `Exclusion BITMAP` to be negated | + +## Return Value + +Returns an integer. +- If the parameter has a null value, returns NULL + +## Examples + +```sql +select bitmap_and_not_count(null, bitmap_from_string('1,2,3')) banc1, bitmap_and_not_count(bitmap_from_string('1,2,3') ,null) banc2; +``` + +```text ++-------+-------+ +| banc1 | banc2 | ++-------+-------+ +| 0 | 0 | ++-------+-------+ +``` + +```sql +select bitmap_and_not_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5')) banc; +``` + +```text +------+ -| cnt | +| banc | +------+ | 2 | +------+ -``` - -### keywords - - BITMAP_AND_NOT_COUNT,BITMAP_ANDNOT_COUNT,BITMAP +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md index beee61656dcce..b7abb3e6d964d 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and-not.md @@ -24,46 +24,78 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and_not,bitmap_andnot -### description -#### Syntax +## Description -`BITMAP BITMAP_AND_NOT(BITMAP lhs, BITMAP rhs)` +Perform a NOT operation on two BITMAPs and return the result. The first input parameter is called `base BITMAP` and the second is called `exclude BITMAP`. -Calculate the set after lhs minus intersection of two input bitmaps, return the new bitmap. +## Alias -### example +- BITMAP_ANDNOT +## Syntax + +```sql +BITMAP_AND_NOT(, ) +``` + +## Parameters + +| Parameter | Description | +|-------------|----------------------------------| +| `` | `Base BITMAP` to be negated | +| `` | `Exclusion BITMAP` to be negated | + +## Return Value + +Returns a BITMAP. +- If the parameter has a null value, returns NULL + +## Examples + +```sql +select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; ``` -mysql> select bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))) cnt; + +```text +------+ | cnt | +------+ | 2 | +------+ +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))); +``` + +```text +--------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'))) | +--------------------------------------------------------------------------------------------+ | 1,2 | +--------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_empty())) ; +```text +-------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), bitmap_empty())) | +-------------------------------------------------------------------------------+ | 1,2,3 | +-------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +``` -mysql> select bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'),NULL)); +```text +---------------------------------------------------------------------+ | bitmap_to_string(bitmap_and_not(bitmap_from_string('1,2,3'), NULL)) | +---------------------------------------------------------------------+ | NULL | +---------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND_NOT,BITMAP_ANDNOT,BITMAP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md index b638a31dcd55d..99630843af578 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-and.md @@ -24,67 +24,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_and -### description -#### Syntax +## Description -`BITMAP BITMAP_AND(BITMAP lhs, BITMAP rhs, ...)` +Computes the intersection of two or more input BITMAPs and returns a new BITMAP. -Compute intersection of two or more input bitmaps, return the new bitmap. +## Syntax -### example +```sql +BITMAP_AND(, ,[, ...]) +``` + +## Parameters + +| Parameter | Description | +|------------|----------------------------------------------------------------| +| `` | One of the original BITMAPs whose intersection is being sought | + +## Return Value +Returns a BITMAP +- If the parameter has a null value, it returns NULL + +## Examples + +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); ``` -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(2))) | -+----------------------------------------------------------+ -| | -+----------------------------------------------------------+ - -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ - -MySQL> select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))); -+----------------------------------------------------------+ -| bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1))) | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ - -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))); + +```text +-----------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) | +-----------------------------------------------------------------------------------------------------------------------+ | 1,2 | +-----------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())); +``` + +```text +---------------------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), bitmap_empty())) | +---------------------------------------------------------------------------------------------------------------------------------------+ | | +---------------------------------------------------------------------------------------------------------------------------------------+ +``` -MySQL> select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +```sql +select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ | bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'), NULL)) | +-----------------------------------------------------------------------------------------------------------------------------+ | NULL | +-----------------------------------------------------------------------------------------------------------------------------+ ``` - -### keywords - - BITMAP_AND,BITMAP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md index 01b8e665cb320..4cf5f7fd04140 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-contains.md @@ -24,32 +24,39 @@ specific language governing permissions and limitations under the License. --> -## bitmap_contains -### description -#### Syntax +## Description -`BOOLEAN BITMAP_CONTAINS(BITMAP bitmap, BIGINT input)` +Calculates whether the input value is in the BITMAP and returns a boolean value. -Calculates whether the input value is in the Bitmap column and returns a Boolean value. - -### example +## Syntax +```sql +BITMAP_CONTAINS(, ) ``` -mysql> select bitmap_contains(to_bitmap(1),2) cnt; -+------+ -| cnt | -+------+ -| 0 | -+------+ - -mysql> select bitmap_contains(to_bitmap(1),1) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ + +## Parameters + +| Parameter | Description | +|------------|-----------------------------------------| +| `` | BITMAP collection | +| `` | The integer to be checked for existence | + +## Return Value + +Returns a boolean +- If the parameter is empty, returns NULL + +## Examples + +```sql +select bitmap_contains(to_bitmap(1),2) cnt1, bitmap_contains(to_bitmap(1),1) cnt2; ``` -### keywords +```text ++------+------+ +| cnt1 | cnt2 | ++------+------+ +| 0 | 1 | ++------+------+ +``` - BITMAP_CONTAINS,BITMAP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md index fb90c995890e5..ccb9e3f66b083 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-count.md @@ -24,33 +24,37 @@ specific language governing permissions and limitations under the License. --> -## bitmap_count -### description -#### Syntax +## Description -`BITMAP BITMAP_COUNT(BITMAP lhs)` +Count the number of elements in the input BITMAP -Returns the number of input bitmaps. +## Syntax -### example +```sql +BITMAP_COUNT() +``` + +## Parameters + +| Parameter | Description | +|------------|-------------| +| `` | a BITMAP | + +## Return Value +Returns an integer + +## Examples + +```sql +select bitmap_count(to_bitmap(1)) cnt; ``` -mysql> select bitmap_count(to_bitmap(1)) cnt; -+------+ -| cnt | -+------+ -| 1 | -+------+ -mysql> select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt; +```text +------+ | cnt | +------+ | 1 | +------+ - ``` -### keywords - - BITMAP_COUNT diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md index 291f926ec2195..429dcfc945e76 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-empty.md @@ -24,29 +24,31 @@ specific language governing permissions and limitations under the License. --> -## bitmap_empty -### description -#### Syntax +## Description -`BITMAP BITMAP_EMPTY()` - -Return an empty bitmap. Mainly be used to supply default value for bitmap column when loading, e.g., +Construct an empty BITMAP. Mainly used to fill default values during insert or stream load. For example: ``` -cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://host:8410/api/test/testDb/_stream_load +cat data | curl --location-trusted -u user:passwd -T - -H "columns: dt,page,v1,v2=bitmap_empty()" http://127.0.0.1:8040/api/test_database/test_table/_stream_load ``` -### example +## Syntax +```sql +BITMAP_EMPTY() ``` -mysql> select bitmap_count(bitmap_empty()); -+------------------------------+ -| bitmap_count(bitmap_empty()) | -+------------------------------+ -| 0 | -+------------------------------+ -mysql> select bitmap_to_string(bitmap_empty()); +## Return Value + +Returns an empty array with no elements + +## Examples + +```sql +select bitmap_to_string(bitmap_empty()); +``` + +```text +----------------------------------+ | bitmap_to_string(bitmap_empty()) | +----------------------------------+ @@ -54,6 +56,14 @@ mysql> select bitmap_to_string(bitmap_empty()); +----------------------------------+ ``` -### keywords +```sql +select bitmap_count(bitmap_empty()); +``` - BITMAP_EMPTY,BITMAP +```text ++------------------------------+ +| bitmap_count(bitmap_empty()) | ++------------------------------+ +| 0 | ++------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md index 6ba524d46733c..dda3105a861ff 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-array.md @@ -22,32 +22,37 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_array +## Description -### description -#### Syntax +Converts an array of TINYINT/SMALLINT/INT/BIGINT type to a BITMAP. When the input field is illegal, the result returns NULL. -`BITMAP BITMAP_FROM_ARRAY(ARRAY input)` +## Syntax -Convert a TINYINT/SMALLINT/INT/BIGINT array to a BITMAP -When the input field is illegal, the result returns NULL +```sql +BITMAP_FROM_ARRAY() +``` -### example +## Parameters -``` -mysql> select *, bitmap_to_string(bitmap_from_array(c_array)) from array_test; -+------+-----------------------+------------------------------------------------+ -| id | c_array | bitmap_to_string(bitmap_from_array(`c_array`)) | -+------+-----------------------+------------------------------------------------+ -| 1 | [NULL] | NULL | -| 2 | [1, 2, 3, NULL] | NULL | -| 2 | [1, 2, 3, -10] | NULL | -| 3 | [1, 2, 3, 4, 5, 6, 7] | 1,2,3,4,5,6,7 | -| 4 | [100, 200, 300, 300] | 100,200,300 | -+------+-----------------------+------------------------------------------------+ -5 rows in set (0.02 sec) -``` +| Parameter | Description | +|-----------|---------------| +| `` | integer array | + +## Return Value -### keywords +Returns a BITMAP +- When the input field is invalid, the result is NULL + +## Examples + +```sql +SELECT bitmap_to_string(bitmap_from_array(array(1, 0, 1, 1, 0, 1, 0))) AS bs; +``` - BITMAP_FROM_ARRAY,BITMAP +```text ++------+ +| bs | ++------+ +| 0,1 | ++------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md index 4a60f9e5fc9d0..5c2278edff910 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-base64.md @@ -22,40 +22,61 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_base64 +## Description -### description -#### Syntax +Convert a base64 string (which can be converted by `bitmap_to_base64` function) to a BITMAP. Returns NULL when the input string is invalid. -`BITMAP BITMAP_FROM_BASE64(VARCHAR input)` +## Syntax -Convert a base64 string(result of function `bitmap_to_base64`) into a bitmap. If input string is invalid, return NULL. +```sql + BITMAP_FROM_BASE64() +``` + +## Parameters + +| Parameter | Description | +|----------------|-----------------------------------------------------------------| +| `` | base64 string (can be converted by `bitmap_to_base64` function) | + +## Return Value + +Returns a BITMAP +- When the input field is invalid, the result is NULL + +## Examples -### example +```sql +select bitmap_to_string(bitmap_from_base64("AA==")) bts; +``` + +```text ++------+ +| bts | ++------+ +| | ++------+ +``` +```sql +select bitmap_to_string(bitmap_from_base64("AQEAAAA=")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_base64("AA==")); -+----------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AA==")) | -+----------------------------------------------+ -| | -+----------------------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AQEAAAA=")); -+-----------------------------------+ -| bitmap_to_string(bitmap_from_base64("AQEAAAA=")) | -+-----------------------------------+ -| 1 | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")); -+----------------------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) | -+----------------------------------------------------------------------------------+ -| 1,9999999 | -+----------------------------------------------------------------------------------+ + +```text ++------+ +| bts | ++------+ +| 1 | ++------+ ``` -### keywords +```sql +select bitmap_to_string(bitmap_from_base64("AjowAAACAAAAAAAAAJgAAAAYAAAAGgAAAAEAf5Y=")) bts; +``` - BITMAP_FROM_BASE64,BITMAP +```text ++-----------+ +| bts | ++-----------+ +| 1,9999999 | ++-----------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md index 672306960b0b4..e835d895d9075 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/bitmap-functions/bitmap-from-string.md @@ -22,42 +22,63 @@ specific language governing permissions and limitations under the License. --> -## bitmap_from_string +## Description -### description -#### Syntax +Convert a string into a BITMAP. The string consists of a group of unsigned bigint numbers separated by commas. (The number values are between: 0 ~ 18446744073709551615) +For example, the string "0, 1, 2" will be converted into a Bitmap, where the 0th, 1st, and 2nd bits are set. When the input field is invalid, NULL is returned -`BITMAP BITMAP_FROM_STRING(VARCHAR input)` +## Syntax -Convert a string into a bitmap. The input string should be a comma separated unsigned bigint (ranging from 0 to 18446744073709551615). -For example: input string "0, 1, 2" will be converted to a Bitmap with bit 0, 1, 2 set. -If input string is invalid, return NULL. +```sql + BITMAP_FROM_STRING() +``` + +## Parameters + +| Parameter | Description | +|-----------|------------------------------------------------------------------------------------------------| +| `` | Array string, for example "0, 1, 2" string will be converted to a Bitmap with bits 0, 1, 2 set | + +## Return Value -### example +Returns a BITMAP +- When the input field is invalid, the result is NULL +## Examples + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 2")) bts; ``` -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 2")); -+-------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 2')) | -+-------------------------------------------------+ -| 0,1,2 | -+-------------------------------------------------+ - -mysql> select bitmap_from_string("-1, 0, 1, 2"); -+-----------------------------------+ -| bitmap_from_string('-1, 0, 1, 2') | -+-----------------------------------+ -| NULL | -+-----------------------------------+ - -mysql> select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")); -+--------------------------------------------------------------------+ -| bitmap_to_string(bitmap_from_string('0, 1, 18446744073709551615')) | -+--------------------------------------------------------------------+ -| 0,1,18446744073709551615 | -+--------------------------------------------------------------------+ + +```text ++-------+ +| bts | ++-------+ +| 0,1,2 | ++-------+ ``` -### keywords +```sql +select bitmap_from_string("-1, 0, 1, 2") bfs; +``` + +```text ++------+ +| bfs | ++------+ +| NULL | ++------+ +``` + +```sql +select bitmap_to_string(bitmap_from_string("0, 1, 18446744073709551615")) bts; +``` + +```text ++--------------------------+ +| bts | ++--------------------------+ +| 0,1,18446744073709551615 | ++--------------------------+ +``` - BITMAP_FROM_STRING,BITMAP