From 43e3fa5e98033c46e429bac45e1fdfe3751e7687 Mon Sep 17 00:00:00 2001 From: boluor Date: Tue, 2 Jun 2026 15:56:28 +0000 Subject: [PATCH] [fix](sql-functions) add example setup tables to aggregate pages in version-3.x / version-2.1 These aggregate-function pages already carry a visible inline setup block (CREATE TABLE + INSERT) on the dev/version-4.x docs, but the version-3.x and version-2.1 copies were missing it, so their `SELECT ... FROM ` examples cannot be run or reproduced ("table does not exist"). Port the same visible inline setup block to the version-3.x and version-2.1 copies (EN + ZH) for the pages where the older docs use the same example and data as 4.x: CORR, CORR_WELFORD (3.x only), COUNT, COVAR, COVAR_SAMP, GROUP_CONCAT, BITMAP_INTERSECT. Verified end-to-end that each example resolves its table and matches that version's documented output: version-3.x on a 3.1.4 cluster and version-2.1 on a 2.1.11 cluster (all pass). Pages whose older-version docs use different tables/data/output than 4.x are intentionally left out of this PR (they need a per-version reconstruction, handled separately). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../aggregate-functions/bitmap-intersect.md | 18 ++++++++++ .../sql-functions/aggregate-functions/corr.md | 21 ++++++++++++ .../aggregate-functions/count.md | 33 +++++++++++++++++++ .../aggregate-functions/covar-samp.md | 17 ++++++++++ .../aggregate-functions/covar.md | 17 ++++++++++ .../aggregate-functions/group-concat.md | 14 ++++++++ .../aggregate-functions/bitmap-intersect.md | 18 ++++++++++ .../aggregate-functions/corr-welford.md | 21 ++++++++++++ .../sql-functions/aggregate-functions/corr.md | 21 ++++++++++++ .../aggregate-functions/count.md | 33 +++++++++++++++++++ .../aggregate-functions/covar-samp.md | 17 ++++++++++ .../aggregate-functions/covar.md | 17 ++++++++++ .../aggregate-functions/group-concat.md | 14 ++++++++ .../aggregate-functions/bitmap-intersect.md | 18 ++++++++++ .../sql-functions/aggregate-functions/corr.md | 21 ++++++++++++ .../aggregate-functions/count.md | 33 +++++++++++++++++++ .../aggregate-functions/covar-samp.md | 17 ++++++++++ .../aggregate-functions/covar.md | 17 ++++++++++ .../aggregate-functions/group-concat.md | 14 ++++++++ .../aggregate-functions/bitmap-intersect.md | 18 ++++++++++ .../aggregate-functions/corr-welford.md | 21 ++++++++++++ .../sql-functions/aggregate-functions/corr.md | 21 ++++++++++++ .../aggregate-functions/count.md | 33 +++++++++++++++++++ .../aggregate-functions/covar-samp.md | 17 ++++++++++ .../aggregate-functions/covar.md | 17 ++++++++++ .../aggregate-functions/group-concat.md | 14 ++++++++ 26 files changed, 522 insertions(+) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md index 2b8605c99aa02..43f0671bbc50b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md @@ -28,6 +28,24 @@ BITMAP_INTERSECT(BITMAP ) ## 举例 +```sql +-- setup +CREATE TABLE user_tags ( + tag VARCHAR(20), + date DATETIME, + user_id BITMAP bitmap_union +) AGGREGATE KEY(tag, date) DISTRIBUTED BY HASH(tag) BUCKETS 1 +PROPERTIES ("replication_num" = "1"); +INSERT INTO user_tags VALUES + ('A', '2020-05-18', to_bitmap(1)), + ('A', '2020-05-18', to_bitmap(2)), + ('A', '2020-05-19', to_bitmap(2)), + ('A', '2020-05-19', to_bitmap(3)), + ('B', '2020-05-18', to_bitmap(4)), + ('B', '2020-05-19', to_bitmap(4)), + ('B', '2020-05-19', to_bitmap(5)); +``` + 表结构 ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/corr.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/corr.md index c15670fadfaa6..0d953289cd116 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/corr.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/corr.md @@ -32,6 +32,27 @@ CORR(, ) ## 举例 +```sql +-- setup +create table test_corr( + id int, + k1 double, + k2 double +) distributed by hash (id) buckets 1 +properties ("replication_num"="1"); + +insert into test_corr values + (1, 20, 22), + (1, 10, 20), + (2, 36, 21), + (2, 30, 22), + (2, 25, 20), + (3, 25, NULL), + (4, 25, 21), + (4, 25, 22), + (4, 25, 20); +``` + ```sql select * from test_corr; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/count.md index f4fffd4e2fb6f..674f100580498 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/count.md @@ -30,6 +30,39 @@ COUNT() ## 举例 +```sql +-- setup +create table test_count( + id int, + name varchar(20), + sex int +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into test_count values + (1, '1', 1), + (2, '2', 1), + (3, '3', 1), + (4, '0', 1), + (4, '4', 1), + (5, NULL, 1); + +create table test_insert( + id int, + name varchar(20), + sex int +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into test_insert values + (1, '1', 1), + (2, '2', 1), + (3, '3', 1), + (4, '0', 1), + (4, '4', 1), + (5, NULL, 1); +``` + ```sql select * from test_count; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar-samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar-samp.md index 95602138cf063..b6ad730ffb482 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar-samp.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar-samp.md @@ -31,6 +31,23 @@ COVAR_SAMP(, ) ## 举例 +```sql +-- setup +create table baseall( + id int, + x double, + y double +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into baseall values + (1, 1.0, 2.0), + (2, 2.0, 3.0), + (3, 3.0, 4.0), + (4, 4.0, NULL), + (5, NULL, 5.0); +``` + ``` select covar_samp(x,y) from baseall; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar.md index ac83cb4c13ade..41defe6f7109c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar.md @@ -35,6 +35,23 @@ COVAR(, ) ## 举例 +```sql +-- setup +create table baseall( + id int, + x double, + y double +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into baseall values + (1, 1.0, 2.0), + (2, 2.0, 3.0), + (3, 3.0, 4.0), + (4, 4.0, NULL), + (5, NULL, 5.0); +``` + ``` select covar(x,y) from baseall; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md index 80b0052a1c11c..d156beebfb5cb 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -31,6 +31,20 @@ GROUP_CONCAT([DISTINCT] [, ] [ORDER BY { | } [ASC | D ## 举例 +```sql +-- setup +create table test( + value varchar(10) +) distributed by hash(value) buckets 1 +properties ("replication_num"="1"); + +insert into test values + ("a"), + ("b"), + ("c"), + ("c"); +``` + ```sql select value from test; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md index 2b8605c99aa02..43f0671bbc50b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md @@ -28,6 +28,24 @@ BITMAP_INTERSECT(BITMAP ) ## 举例 +```sql +-- setup +CREATE TABLE user_tags ( + tag VARCHAR(20), + date DATETIME, + user_id BITMAP bitmap_union +) AGGREGATE KEY(tag, date) DISTRIBUTED BY HASH(tag) BUCKETS 1 +PROPERTIES ("replication_num" = "1"); +INSERT INTO user_tags VALUES + ('A', '2020-05-18', to_bitmap(1)), + ('A', '2020-05-18', to_bitmap(2)), + ('A', '2020-05-19', to_bitmap(2)), + ('A', '2020-05-19', to_bitmap(3)), + ('B', '2020-05-18', to_bitmap(4)), + ('B', '2020-05-19', to_bitmap(4)), + ('B', '2020-05-19', to_bitmap(5)); +``` + 表结构 ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md index ad610816571e5..6286cac6ed94a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md @@ -32,6 +32,27 @@ CORR_WELFORD(, ) ## 举例 +```sql +-- setup +create table test_corr( + id int, + k1 double, + k2 double +) distributed by hash (id) buckets 1 +properties ("replication_num"="1"); + +insert into test_corr values + (1, 20, 22), + (1, 10, 20), + (2, 36, 21), + (2, 30, 22), + (2, 25, 20), + (3, 25, NULL), + (4, 25, 21), + (4, 25, 22), + (4, 25, 20); +``` + ```sql select * from test_corr; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr.md index c15670fadfaa6..0d953289cd116 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr.md @@ -32,6 +32,27 @@ CORR(, ) ## 举例 +```sql +-- setup +create table test_corr( + id int, + k1 double, + k2 double +) distributed by hash (id) buckets 1 +properties ("replication_num"="1"); + +insert into test_corr values + (1, 20, 22), + (1, 10, 20), + (2, 36, 21), + (2, 30, 22), + (2, 25, 20), + (3, 25, NULL), + (4, 25, 21), + (4, 25, 22), + (4, 25, 20); +``` + ```sql select * from test_corr; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/count.md index f4fffd4e2fb6f..674f100580498 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/count.md @@ -30,6 +30,39 @@ COUNT() ## 举例 +```sql +-- setup +create table test_count( + id int, + name varchar(20), + sex int +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into test_count values + (1, '1', 1), + (2, '2', 1), + (3, '3', 1), + (4, '0', 1), + (4, '4', 1), + (5, NULL, 1); + +create table test_insert( + id int, + name varchar(20), + sex int +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into test_insert values + (1, '1', 1), + (2, '2', 1), + (3, '3', 1), + (4, '0', 1), + (4, '4', 1), + (5, NULL, 1); +``` + ```sql select * from test_count; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar-samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar-samp.md index 95602138cf063..b6ad730ffb482 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar-samp.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar-samp.md @@ -31,6 +31,23 @@ COVAR_SAMP(, ) ## 举例 +```sql +-- setup +create table baseall( + id int, + x double, + y double +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into baseall values + (1, 1.0, 2.0), + (2, 2.0, 3.0), + (3, 3.0, 4.0), + (4, 4.0, NULL), + (5, NULL, 5.0); +``` + ``` select covar_samp(x,y) from baseall; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar.md index ac83cb4c13ade..41defe6f7109c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar.md @@ -35,6 +35,23 @@ COVAR(, ) ## 举例 +```sql +-- setup +create table baseall( + id int, + x double, + y double +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into baseall values + (1, 1.0, 2.0), + (2, 2.0, 3.0), + (3, 3.0, 4.0), + (4, 4.0, NULL), + (5, NULL, 5.0); +``` + ``` select covar(x,y) from baseall; ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/group-concat.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/group-concat.md index 90c514ed265d6..ad8fa3959ecb1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -31,6 +31,20 @@ GROUP_CONCAT([DISTINCT] [, ] [ORDER BY { | } [ASC | D ## 举例 +```sql +-- setup +create table test( + value varchar(10) +) distributed by hash(value) buckets 1 +properties ("replication_num"="1"); + +insert into test values + ("a"), + ("b"), + ("c"), + ("c"); +``` + ```sql select value from test; ``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md index 6ad2a367dbff2..bc0552607b231 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md @@ -28,6 +28,24 @@ The data type of the return value is BITMAP. ## Example +```sql +-- setup +CREATE TABLE user_tags ( + tag VARCHAR(20), + date DATETIME, + user_id BITMAP bitmap_union +) AGGREGATE KEY(tag, date) DISTRIBUTED BY HASH(tag) BUCKETS 1 +PROPERTIES ("replication_num" = "1"); +INSERT INTO user_tags VALUES + ('A', '2020-05-18', to_bitmap(1)), + ('A', '2020-05-18', to_bitmap(2)), + ('A', '2020-05-19', to_bitmap(2)), + ('A', '2020-05-19', to_bitmap(3)), + ('B', '2020-05-18', to_bitmap(4)), + ('B', '2020-05-19', to_bitmap(4)), + ('B', '2020-05-19', to_bitmap(5)); +``` + Table schema ``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/corr.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/corr.md index 50033121cac8d..70f65de2a3f90 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/corr.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/corr.md @@ -32,6 +32,27 @@ The return value is of type DOUBLE, the covariance of expr1 and expr2, except th ## Example +```sql +-- setup +create table test_corr( + id int, + k1 double, + k2 double +) distributed by hash (id) buckets 1 +properties ("replication_num"="1"); + +insert into test_corr values + (1, 20, 22), + (1, 10, 20), + (2, 36, 21), + (2, 30, 22), + (2, 25, 20), + (3, 25, NULL), + (4, 25, 21), + (4, 25, 22), + (4, 25, 20); +``` + ```sql select * from test_corr; ``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/count.md index cce0ff89bbe84..c683596f619ae 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/count.md @@ -30,6 +30,39 @@ The return value is of numeric type. If expr is NULL, there will be no parameter ## Example +```sql +-- setup +create table test_count( + id int, + name varchar(20), + sex int +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into test_count values + (1, '1', 1), + (2, '2', 1), + (3, '3', 1), + (4, '0', 1), + (4, '4', 1), + (5, NULL, 1); + +create table test_insert( + id int, + name varchar(20), + sex int +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into test_insert values + (1, '1', 1), + (2, '2', 1), + (3, '3', 1), + (4, '0', 1), + (4, '4', 1), + (5, NULL, 1); +``` + ```sql select * from test_count; ``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar-samp.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar-samp.md index 23961435523a0..08e2f28c833e2 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar-samp.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar-samp.md @@ -31,6 +31,23 @@ Returns the sample covariance of expr1 and expr2, special case: ## Example +```sql +-- setup +create table baseall( + id int, + x double, + y double +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into baseall values + (1, 1.0, 2.0), + (2, 2.0, 3.0), + (3, 3.0, 4.0), + (4, 4.0, NULL), + (5, NULL, 5.0); +``` + ``` select covar_samp(x,y) from baseall; ``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar.md index 1aea2b188f5ff..831d941e53e4f 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/covar.md @@ -35,6 +35,23 @@ Returns the covariance value of expr1 and expr2, special case: ## Example +```sql +-- setup +create table baseall( + id int, + x double, + y double +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into baseall values + (1, 1.0, 2.0), + (2, 2.0, 3.0), + (3, 3.0, 4.0), + (4, 4.0, NULL), + (5, NULL, 5.0); +``` + ``` select covar(x,y) from baseall; ``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md index 924ae154c6af3..5a194ea768769 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -31,6 +31,20 @@ Returns a value of type VARCHAR. ## Example +```sql +-- setup +create table test( + value varchar(10) +) distributed by hash(value) buckets 1 +properties ("replication_num"="1"); + +insert into test values + ("a"), + ("b"), + ("c"), + ("c"); +``` + ```sql select value from test; ``` diff --git a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md index 6ad2a367dbff2..bc0552607b231 100644 --- a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md +++ b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/bitmap-intersect.md @@ -28,6 +28,24 @@ The data type of the return value is BITMAP. ## Example +```sql +-- setup +CREATE TABLE user_tags ( + tag VARCHAR(20), + date DATETIME, + user_id BITMAP bitmap_union +) AGGREGATE KEY(tag, date) DISTRIBUTED BY HASH(tag) BUCKETS 1 +PROPERTIES ("replication_num" = "1"); +INSERT INTO user_tags VALUES + ('A', '2020-05-18', to_bitmap(1)), + ('A', '2020-05-18', to_bitmap(2)), + ('A', '2020-05-19', to_bitmap(2)), + ('A', '2020-05-19', to_bitmap(3)), + ('B', '2020-05-18', to_bitmap(4)), + ('B', '2020-05-19', to_bitmap(4)), + ('B', '2020-05-19', to_bitmap(5)); +``` + Table schema ``` diff --git a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md index 35dbf1e8c01d8..9f79466a84330 100644 --- a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md +++ b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr-welford.md @@ -32,6 +32,27 @@ The return value is of type DOUBLE, the covariance of expr1 and expr2, except th ## Example +```sql +-- setup +create table test_corr( + id int, + k1 double, + k2 double +) distributed by hash (id) buckets 1 +properties ("replication_num"="1"); + +insert into test_corr values + (1, 20, 22), + (1, 10, 20), + (2, 36, 21), + (2, 30, 22), + (2, 25, 20), + (3, 25, NULL), + (4, 25, 21), + (4, 25, 22), + (4, 25, 20); +``` + ```sql select * from test_corr; ``` diff --git a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr.md b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr.md index 50033121cac8d..70f65de2a3f90 100644 --- a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr.md +++ b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/corr.md @@ -32,6 +32,27 @@ The return value is of type DOUBLE, the covariance of expr1 and expr2, except th ## Example +```sql +-- setup +create table test_corr( + id int, + k1 double, + k2 double +) distributed by hash (id) buckets 1 +properties ("replication_num"="1"); + +insert into test_corr values + (1, 20, 22), + (1, 10, 20), + (2, 36, 21), + (2, 30, 22), + (2, 25, 20), + (3, 25, NULL), + (4, 25, 21), + (4, 25, 22), + (4, 25, 20); +``` + ```sql select * from test_corr; ``` diff --git a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/count.md b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/count.md index cce0ff89bbe84..c683596f619ae 100644 --- a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/count.md +++ b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/count.md @@ -30,6 +30,39 @@ The return value is of numeric type. If expr is NULL, there will be no parameter ## Example +```sql +-- setup +create table test_count( + id int, + name varchar(20), + sex int +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into test_count values + (1, '1', 1), + (2, '2', 1), + (3, '3', 1), + (4, '0', 1), + (4, '4', 1), + (5, NULL, 1); + +create table test_insert( + id int, + name varchar(20), + sex int +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into test_insert values + (1, '1', 1), + (2, '2', 1), + (3, '3', 1), + (4, '0', 1), + (4, '4', 1), + (5, NULL, 1); +``` + ```sql select * from test_count; ``` diff --git a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar-samp.md b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar-samp.md index 23961435523a0..08e2f28c833e2 100644 --- a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar-samp.md +++ b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar-samp.md @@ -31,6 +31,23 @@ Returns the sample covariance of expr1 and expr2, special case: ## Example +```sql +-- setup +create table baseall( + id int, + x double, + y double +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into baseall values + (1, 1.0, 2.0), + (2, 2.0, 3.0), + (3, 3.0, 4.0), + (4, 4.0, NULL), + (5, NULL, 5.0); +``` + ``` select covar_samp(x,y) from baseall; ``` diff --git a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar.md b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar.md index 1aea2b188f5ff..831d941e53e4f 100644 --- a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar.md +++ b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/covar.md @@ -35,6 +35,23 @@ Returns the covariance value of expr1 and expr2, special case: ## Example +```sql +-- setup +create table baseall( + id int, + x double, + y double +) distributed by hash(id) buckets 1 +properties ("replication_num"="1"); + +insert into baseall values + (1, 1.0, 2.0), + (2, 2.0, 3.0), + (3, 3.0, 4.0), + (4, 4.0, NULL), + (5, NULL, 5.0); +``` + ``` select covar(x,y) from baseall; ``` diff --git a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/group-concat.md b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/group-concat.md index 1147d8577bfa6..9face3c3b06a5 100644 --- a/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/versioned_docs/version-3.x/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -31,6 +31,20 @@ Returns a value of type VARCHAR. ## Example +```sql +-- setup +create table test( + value varchar(10) +) distributed by hash(value) buckets 1 +properties ("replication_num"="1"); + +insert into test values + ("a"), + ("b"), + ("c"), + ("c"); +``` + ```sql select value from test; ```