This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new a8e74d6a85b [Fix](statistics)Fix analyze min max sql syntax error.
#26240 (#26443)
a8e74d6a85b is described below
commit a8e74d6a85b8f313623c4ddf6811058593335775
Author: Jibing-Li <[email protected]>
AuthorDate: Mon Nov 6 14:13:49 2023 +0800
[Fix](statistics)Fix analyze min max sql syntax error. #26240 (#26443)
backport #26240
---
.../hive/scripts/create_preinstalled_table.hql | 2 +-
.../apache/doris/statistics/BaseAnalysisTask.java | 4 ++--
.../hive/test_hive_statistics_p0.groovy | 20 ++++++++++----------
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git
a/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_table.hql
b/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_table.hql
index 6b3e04e25b3..740bf2fa584 100644
---
a/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_table.hql
+++
b/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_table.hql
@@ -1772,4 +1772,4 @@ create table stats_test1 (id INT, value STRING) STORED AS
ORC;
create table stats_test2 (id INT, value STRING) STORED AS PARQUET;
insert into stats_test1 values (1, 'name1'), (2, 'name2'), (3, 'name3');
-insert into stats_test2 values (1, 'name1'), (2, 'name2'), (3, 'name3');
+INSERT INTO stats_test2 VALUES (1, ';'), (2, '\*');
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/statistics/BaseAnalysisTask.java
b/fe/fe-core/src/main/java/org/apache/doris/statistics/BaseAnalysisTask.java
index a73d2a2c06b..4f7d588de73 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/BaseAnalysisTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/BaseAnalysisTask.java
@@ -242,7 +242,7 @@ public abstract class BaseAnalysisTask {
// Min value is not accurate while sample, so set it to NULL to avoid
optimizer generate bad plan.
protected String getMinFunction() {
if (tableSample == null) {
- return "MIN(CAST(min AS ${type}))";
+ return "CAST(MIN(`${colName}`) as ${type}) ";
} else {
return "NULL ";
}
@@ -251,7 +251,7 @@ public abstract class BaseAnalysisTask {
// Max value is not accurate while sample, so set it to NULL to avoid
optimizer generate bad plan.
protected String getMaxFunction() {
if (tableSample == null) {
- return "MAX(CAST(min AS ${type}))";
+ return "CAST(MAX(`${colName}`) as ${type}) ";
} else {
return "NULL ";
}
diff --git
a/regression-test/suites/external_table_p0/hive/test_hive_statistics_p0.groovy
b/regression-test/suites/external_table_p0/hive/test_hive_statistics_p0.groovy
index 501daaf8577..38db4379a90 100644
---
a/regression-test/suites/external_table_p0/hive/test_hive_statistics_p0.groovy
+++
b/regression-test/suites/external_table_p0/hive/test_hive_statistics_p0.groovy
@@ -55,24 +55,24 @@ suite("test_hive_statistics_p0",
"all_types,p0,external,hive,external_docker,ext
result = sql """show column stats stats_test2(id);"""
assertEquals(1, result.size())
assertEquals("id", result[0][0])
- assertEquals("3.0", result[0][1])
- assertEquals("3.0", result[0][2])
+ assertEquals("2.0", result[0][1])
+ assertEquals("2.0", result[0][2])
assertEquals("0.0", result[0][3])
- assertEquals("12.0", result[0][4])
+ assertEquals("8.0", result[0][4])
assertEquals("4.0", result[0][5])
assertEquals("1", result[0][6])
- assertEquals("3", result[0][7])
+ assertEquals("2", result[0][7])
result = sql """show column stats stats_test2(value);"""
assertEquals(1, result.size())
assertEquals("value", result[0][0])
- assertEquals("3.0", result[0][1])
- assertEquals("3.0", result[0][2])
+ assertEquals("2.0", result[0][1])
+ assertEquals("2.0", result[0][2])
assertEquals("0.0", result[0][3])
- assertEquals("15.0", result[0][4])
- assertEquals("5.0", result[0][5])
- assertEquals("\'name1\'", result[0][6])
- assertEquals("\'name3\'", result[0][7])
+ assertEquals("2.0", result[0][4])
+ assertEquals("1.0", result[0][5])
+ assertEquals("\'*\'", result[0][6])
+ assertEquals("\';\'", result[0][7])
sql """drop catalog if exists ${catalog_name}"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]