You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/07/20 14:06:53 UTC
[doris] 09/21: [fix](planner)only forbid literal value in AnalyticExpr's order by list (#21819)
This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 05f314193f1e4e9fabbdee9f66375f0da9bf6361
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Wed Jul 19 09:40:55 2023 +0800
[fix](planner)only forbid literal value in AnalyticExpr's order by list (#21819)
* [fix](planner)only forbid literal value in AnalyticExpr's order by list
---
.../org/apache/doris/analysis/AnalyticExpr.java | 4 +--
.../conditional_functions/test_nullif.out | 4 +++
.../conditional_functions/test_nullif.groovy | 35 ++++++++++++++++++++++
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
index 04ab5d0fa3..2a9e9a9c88 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
@@ -465,7 +465,7 @@ public class AnalyticExpr extends Expr {
type = getFnCall().getType();
for (Expr e : partitionExprs) {
- if (e.isConstant()) {
+ if (e.isLiteral()) {
throw new AnalysisException(
"Expressions in the PARTITION BY clause must not be constant: "
+ e.toSql() + " (in " + toSql() + ")");
@@ -473,7 +473,7 @@ public class AnalyticExpr extends Expr {
}
for (OrderByElement e : orderByElements) {
- if (e.getExpr().isConstant()) {
+ if (e.getExpr().isLiteral()) {
throw new AnalysisException(
"Expressions in the ORDER BY clause must not be constant: "
+ e.getExpr().toSql() + " (in " + toSql() + ")");
diff --git a/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out b/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
index f0746996f0..12fcd68da3 100644
--- a/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
+++ b/regression-test/data/query_p0/sql_functions/conditional_functions/test_nullif.out
@@ -570,3 +570,7 @@ null 12 1 true
-- !if_nullif28 --
2020-02-09
+-- !if_nullif29 --
+1 1
+2 2
+
diff --git a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
index fb305884cc..6d1a5948a4 100644
--- a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
+++ b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nullif.groovy
@@ -151,4 +151,39 @@ suite("test_nullif") {
qt_if_nullif27 """select ifnull(2+3, 2), ifnull((3*1 > 1 || 1>0), 2), ifnull((3*1 > 1 or 1>0), 2),
ifnull(upper("null"), concat("NUL", "LL"))"""
qt_if_nullif28 """select ifnull(date(substring("2020-02-09", 1, 1024)), null)"""
+
+ def tableName2 = "testsort"
+
+ sql """ DROP TABLE IF EXISTS ${tableName2}; """
+ sql """
+ CREATE TABLE IF NOT EXISTS ${tableName2} (
+ c_int int NULL COMMENT "",
+ c_pv bitmap BITMAP_UNION NULL COMMENT ""
+ )
+ AGGREGATE KEY(c_int)
+ DISTRIBUTED BY HASH(c_int) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1"
+ );
+ """
+ sql """ INSERT INTO ${tableName2} VALUES(1, to_bitmap(1)), (2, to_bitmap(2));"""
+
+ qt_if_nullif29 """
+ select
+ sortNum,
+ BITMAP_UNION_COUNT (c.pv) over (ORDER BY sortNum ) totalNum
+ from(
+ select
+ ifnull(a.sortNum, b.sortNum) sortNum,
+ BITMAP_UNION (ifnull(a.c_pv, b.c_pv)) pv
+ from
+ (select 1 sortNum, c_pv from ${tableName2} t where t.c_int = 1) a
+ full join
+ (select 2 sortNum, c_pv from ${tableName2} t where t.c_int = 2) b
+ on a.sortNum = b.sortNum
+ GROUP BY
+ sortNum
+ ORDER BY
+ sortNum
+ ) c;"""
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org