This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 171e48865f [fix](planner)only forbid literal value in AnalyticExpr's 
order by list (#21820)
171e48865f is described below

commit 171e48865fe0e65d2ffa233a00a75e85613eeeda
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed Jul 19 13:54:39 2023 +0800

    [fix](planner)only forbid literal value in AnalyticExpr's order by list 
(#21820)
    
    pick from master https://github.com/apache/doris/pull/21819
    
    The original error is the window function's order by clause doesn't support 
a literal value. But we use Expr's isConstant method to check if it's an 
literal, this is wrong. So the pr uses the correct method( isLiteral ) to check 
if an expr is literal to solve this problem
    
    ```sql
    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
    ```
---
 fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java | 4 ++--
 1 file changed, 2 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 f5f1aa5397..8892cf9291 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
@@ -478,7 +478,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() + ")");
@@ -486,7 +486,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() + ")");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to