This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new f443ebfd9a [Improvement](statistics) optimise histogram keyword
(#16369)
f443ebfd9a is described below
commit f443ebfd9a16c7ca365e8ddd0cd96dbfb533bfd8
Author: ElvinWei <[email protected]>
AuthorDate: Fri Feb 3 23:02:41 2023 +0800
[Improvement](statistics) optimise histogram keyword (#16369)
---
.../sql-functions/aggregate-functions/histogram.md | 4 +--
.../sql-functions/aggregate-functions/histogram.md | 4 +--
fe/fe-core/src/main/cup/sql_parser.cup | 2 ++
.../org/apache/doris/statistics/HistogramTask.java | 2 +-
.../test_aggregate_histogram.groovy | 34 +++++++++++-----------
.../test_aggregate_histogram.groovy | 34 +++++++++++-----------
6 files changed, 41 insertions(+), 39 deletions(-)
diff --git
a/docs/en/docs/sql-manual/sql-functions/aggregate-functions/histogram.md
b/docs/en/docs/sql-manual/sql-functions/aggregate-functions/histogram.md
index 98dfd87ba4..32a57c8735 100644
--- a/docs/en/docs/sql-manual/sql-functions/aggregate-functions/histogram.md
+++ b/docs/en/docs/sql-manual/sql-functions/aggregate-functions/histogram.md
@@ -47,14 +47,14 @@ Alias function: `hist(expr[, DOUBLE sample_rate, INT
max_bucket_num])`
### example
```
-MySQL [test]> SELECT `histogram`(c_float) FROM histogram_test;
+MySQL [test]> SELECT histogram(c_float) FROM histogram_test;
+-------------------------------------------------------------------------------------------------------------------------------------+
| histogram(`c_float`)
|
+-------------------------------------------------------------------------------------------------------------------------------------+
|
{"sample_rate":0.2,"max_bucket_num":128,"bucket_num":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]}
|
+-------------------------------------------------------------------------------------------------------------------------------------+
-MySQL [test]> SELECT `histogram`(c_string, 0.5, 2) FROM histogram_test;
+MySQL [test]> SELECT histogram(c_string, 0.5, 2) FROM histogram_test;
+-------------------------------------------------------------------------------------------------------------------------------------+
| histogram(`c_string`)
|
+-------------------------------------------------------------------------------------------------------------------------------------+
diff --git
a/docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/histogram.md
b/docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/histogram.md
index d4cf67ded2..891adb4776 100644
--- a/docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/histogram.md
+++ b/docs/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/histogram.md
@@ -49,14 +49,14 @@ histogram(直方图)函数用于描述数据分布情况,它使用“等
### example
```
-MySQL [test]> SELECT `histogram`(c_float) FROM histogram_test;
+MySQL [test]> SELECT histogram(c_float) FROM histogram_test;
+-------------------------------------------------------------------------------------------------------------------------------------+
| histogram(`c_float`)
|
+-------------------------------------------------------------------------------------------------------------------------------------+
|
{"sample_rate":0.2,"max_bucket_num":128,"bucket_num":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]}
|
+-------------------------------------------------------------------------------------------------------------------------------------+
-MySQL [test]> SELECT `histogram`(c_string, 0.5, 2) FROM histogram_test;
+MySQL [test]> SELECT histogram(c_string, 0.5, 2) FROM histogram_test;
+-------------------------------------------------------------------------------------------------------------------------------------+
| histogram(`c_string`)
|
+-------------------------------------------------------------------------------------------------------------------------------------+
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup
b/fe/fe-core/src/main/cup/sql_parser.cup
index 9dd51f2657..1873ecf5fe 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -7077,6 +7077,8 @@ keyword ::=
{: RESULT = id; :}
| KW_IGNORE:id
{: RESULT = id; :}
+ | KW_HISTOGRAM:id
+ {: RESULT = id; :}
;
// Identifier that contain keyword
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/statistics/HistogramTask.java
b/fe/fe-core/src/main/java/org/apache/doris/statistics/HistogramTask.java
index cc349e0425..a58696c542 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/HistogramTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/HistogramTask.java
@@ -45,7 +45,7 @@ public class HistogramTask extends BaseAnalysisTask {
+ " ${idxId} AS idx_id, "
+ " '${colId}' AS col_id, "
+ " ${sampleRate} AS sample_rate, "
- + " `HISTOGRAM`(`${colName}`, 1, ${maxBucketNum}) AS buckets, "
+ + " HISTOGRAM(`${colName}`, 1, ${maxBucketNum}) AS buckets, "
+ " NOW() AS create_time "
+ "FROM "
+ " `${dbName}`.`${tblName}` TABLESAMPLE (${percentValue}
PERCENT)";
diff --git
a/regression-test/suites/nereids_p0/sql_functions/aggregate_functions/test_aggregate_histogram.groovy
b/regression-test/suites/nereids_p0/sql_functions/aggregate_functions/test_aggregate_histogram.groovy
index 28b4320133..d55264e1fe 100644
---
a/regression-test/suites/nereids_p0/sql_functions/aggregate_functions/test_aggregate_histogram.groovy
+++
b/regression-test/suites/nereids_p0/sql_functions/aggregate_functions/test_aggregate_histogram.groovy
@@ -107,23 +107,23 @@ suite("test_aggregate_histogram") {
// Nereids does't support decimalV3 function
// qt_select """
// SELECT
- // `histogram`(c_bool, 1.0, 1),
- // `histogram`(c_tinyint, 1.0, 1),
- // `histogram`(c_smallint, 1.0, 1),
- // `histogram`(c_bigint, 1.0, 1),
- // `histogram`(c_largeint, 1.0, 1),
- // `histogram`(c_float, 1.0, 1),
- // `histogram`(c_double, 1.0, 1),
- // `histogram`(c_decimal, 1.0, 1),
- // `histogram`(c_decimalv3, 1.0, 1),
- // `histogram`(c_char, 1.0, 1),
- // `histogram`(c_varchar, 1.0, 1),
- // `histogram`(c_string, 1.0, 1),
- // `histogram`(c_date, 1.0, 1),
- // `histogram`(c_datev2, 1.0, 1),
- // `histogram`(c_date_time, 1.0, 1),
- // `histogram`(c_date_timev2, 1.0, 1),
- // `histogram`(c_string_not_null, 1.0, 1)
+ // histogram(c_bool, 1.0, 1),
+ // histogram(c_tinyint, 1.0, 1),
+ // histogram(c_smallint, 1.0, 1),
+ // histogram(c_bigint, 1.0, 1),
+ // histogram(c_largeint, 1.0, 1),
+ // histogram(c_float, 1.0, 1),
+ // histogram(c_double, 1.0, 1),
+ // histogram(c_decimal, 1.0, 1),
+ // histogram(c_decimalv3, 1.0, 1),
+ // histogram(c_char, 1.0, 1),
+ // histogram(c_varchar, 1.0, 1),
+ // histogram(c_string, 1.0, 1),
+ // histogram(c_date, 1.0, 1),
+ // histogram(c_datev2, 1.0, 1),
+ // histogram(c_date_time, 1.0, 1),
+ // histogram(c_date_timev2, 1.0, 1),
+ // histogram(c_string_not_null, 1.0, 1)
// FROM
// ${tableName}
// """
diff --git
a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_histogram.groovy
b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_histogram.groovy
index a9d3e458a2..43caa6fd03 100644
---
a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_histogram.groovy
+++
b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_aggregate_histogram.groovy
@@ -103,23 +103,23 @@ suite("test_aggregate_histogram") {
// Test without GROUP BY
qt_select """
SELECT
- `histogram`(c_bool, 1.0, 1),
- `histogram`(c_tinyint, 1.0, 1),
- `histogram`(c_smallint, 1.0, 1),
- `histogram`(c_bigint, 1.0, 1),
- `histogram`(c_largeint, 1.0, 1),
- `histogram`(c_float, 1.0, 1),
- `histogram`(c_double, 1.0, 1),
- `histogram`(c_decimal, 1.0, 1),
- `histogram`(c_decimalv3, 1.0, 1),
- `histogram`(c_char, 1.0, 1),
- `histogram`(c_varchar, 1.0, 1),
- `histogram`(c_string, 1.0, 1),
- `histogram`(c_date, 1.0, 1),
- `histogram`(c_datev2, 1.0, 1),
- `histogram`(c_date_time, 1.0, 1),
- `histogram`(c_date_timev2, 1.0, 1),
- `histogram`(c_string_not_null, 1.0, 1)
+ histogram(c_bool, 1.0, 1),
+ histogram(c_tinyint, 1.0, 1),
+ histogram(c_smallint, 1.0, 1),
+ histogram(c_bigint, 1.0, 1),
+ histogram(c_largeint, 1.0, 1),
+ histogram(c_float, 1.0, 1),
+ histogram(c_double, 1.0, 1),
+ histogram(c_decimal, 1.0, 1),
+ histogram(c_decimalv3, 1.0, 1),
+ histogram(c_char, 1.0, 1),
+ histogram(c_varchar, 1.0, 1),
+ histogram(c_string, 1.0, 1),
+ histogram(c_date, 1.0, 1),
+ histogram(c_datev2, 1.0, 1),
+ histogram(c_date_time, 1.0, 1),
+ histogram(c_date_timev2, 1.0, 1),
+ histogram(c_string_not_null, 1.0, 1)
FROM
${tableName}
"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]