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

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

commit 5a7e8495e636576c17ea7f60c9a8d9685c7e0950
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Sep 22 19:31:29 2023 +0800

    [fix](planner)SelectStmt's constructor should initialize originSelectList 
member (#24755)
    
    resetSelectList method will use originSelectList to recover the origin 
select list. If the originSelectList is lost in constructor, the 
resetSelectList will fail to recover and make the analyze process fail.
---
 .../java/org/apache/doris/analysis/SelectStmt.java |  1 +
 .../test_inlineview_with_window_function.out       |  4 ++
 .../test_inlineview_with_window_function.groovy    | 81 ++++++++++++++++++++++
 3 files changed, 86 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 1ed0960411c..6cc606b204b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -164,6 +164,7 @@ public class SelectStmt extends QueryStmt {
         this.id = other.id;
         selectList = other.selectList.clone();
         fromClause = other.fromClause.clone();
+        originSelectList = other.originSelectList != null ? 
other.originSelectList.clone() : null;
         whereClause = (other.whereClause != null) ? other.whereClause.clone() 
: null;
         groupByClause = (other.groupByClause != null) ? 
other.groupByClause.clone() : null;
         havingClause = (other.havingClause != null) ? 
other.havingClause.clone() : null;
diff --git 
a/regression-test/data/correctness_p0/test_inlineview_with_window_function.out 
b/regression-test/data/correctness_p0/test_inlineview_with_window_function.out
new file mode 100644
index 00000000000..281bf5dd1b2
--- /dev/null
+++ 
b/regression-test/data/correctness_p0/test_inlineview_with_window_function.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !order --
+2023-06-10     cib2205045_1_1s 0.0000  168939.0        0.0000  0.0     0.0000  
0.0     0.0000  day
+
diff --git 
a/regression-test/suites/correctness_p0/test_inlineview_with_window_function.groovy
 
b/regression-test/suites/correctness_p0/test_inlineview_with_window_function.groovy
index 0da26ff8f37..cdeb65e9ec5 100644
--- 
a/regression-test/suites/correctness_p0/test_inlineview_with_window_function.groovy
+++ 
b/regression-test/suites/correctness_p0/test_inlineview_with_window_function.groovy
@@ -70,4 +70,85 @@ suite("test_inlineview_with_window_function") {
     sql """
         drop table if exists test_table_bb;
     """
+
+    sql """drop table if exists test_table_aaa;"""
+    sql """drop table if exists test_table_bbb;"""
+    sql """CREATE TABLE `test_table_aaa` (
+            `ordernum` varchar(65533) NOT NULL ,
+            `dnt` datetime NOT NULL ,
+            `data` json NULL 
+            ) ENGINE=OLAP
+            DUPLICATE KEY(`ordernum`, `dnt`)
+            COMMENT 'OLAP'
+            DISTRIBUTED BY HASH(`ordernum`) BUCKETS 3
+            PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+            );"""
+
+    sql """CREATE TABLE `test_table_bbb` (
+            `dnt` varchar(200) NULL,
+            `ordernum` varchar(200) NULL,
+            `type` varchar(20) NULL,
+            `powers` double SUM NULL,
+            `p0` double REPLACE NULL,
+            `heatj` double SUM NULL,
+            `j0` double REPLACE NULL,
+            `heatg` double SUM NULL,
+            `g0` double REPLACE NULL,
+            `solar` double SUM NULL
+            ) ENGINE=OLAP
+            AGGREGATE KEY(`dnt`, `ordernum`, `type`)
+            COMMENT 'OLAP'
+            DISTRIBUTED BY HASH(`ordernum`) BUCKETS 1
+            PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+            ); """
+
+    sql """DROP MATERIALIZED VIEW IF EXISTS ods_zn_dnt_max1 ON 
test_table_aaa;"""
+    sql """create materialized view ods_zn_dnt_max1 as
+            select ordernum,max(dnt) as dnt from test_table_aaa
+            group by ordernum
+            ORDER BY ordernum;"""
+
+    sql """insert into test_table_aaa values('cib2205045_1_1s','2023/6/10 
3:55:33','{"DB1":168939,"DNT":"2023-06-10 03:55:33"}');"""
+    sql """insert into test_table_aaa values('cib2205045_1_1s','2023/6/10 
3:56:33','{"DB1":168939,"DNT":"2023-06-10 03:56:33"}');"""
+    sql """insert into test_table_aaa values('cib2205045_1_1s','2023/6/10 
3:57:33','{"DB1":168939,"DNT":"2023-06-10 03:57:33"}');"""
+    sql """insert into test_table_aaa values('cib2205045_1_1s','2023/6/10 
3:58:33','{"DB1":168939,"DNT":"2023-06-10 03:58:33"}');"""
+
+    qt_order """select
+                '2023-06-10',
+                tmp.ordernum,
+                cast(nvl(if(tmp.p0-tmp1.p0>0,tmp.p0-tmp1.p0,tmp.p0-tmp.p1),0) 
as decimal(10,4)),
+                nvl(tmp.p0,0),
+                
cast(nvl(if(tmp.j0-tmp1.j0>0,tmp.j0-tmp1.j0,tmp.j0-tmp.j1)*277.78,0) as 
decimal(10,4)),
+                nvl(tmp.j0,0),
+                
cast(nvl(if(tmp.g0-tmp1.g0>0,tmp.g0-tmp1.g0,tmp.g0-tmp.g1)*277.78,0) as 
decimal(10,4)),
+                nvl(tmp.g0,0),
+                cast(nvl(tmp.solar,0) as decimal(20,4)),
+                'day'
+                from 
+                (
+                select
+                    ordernum,
+                    max(ljrl1) g0,min(ljrl1) g1,
+                    max(ljrl2) j0,min(ljrl2) j1,
+                    max(db1) p0,min(db1) p1,
+                    max(fzl)*1600*0.278 solar
+                from(
+                    select ordernum,dnt,
+                            cast(if(json_extract(data,'\$.LJRL1')=0 or 
json_extract(data,'\$.LJRL1') like '%E%',null,json_extract(data,'\$.LJRL1')) as 
double) ljrl1,
+                            cast(if(json_extract(data,'\$.LJRL2')=0 or 
json_extract(data,'\$.LJRL2') like '%E%',null,json_extract(data,'\$.LJRL2')) as 
double) ljrl2,
+                            first_value(cast(if(json_extract(data,'\$.FZL')=0 
or json_extract(data,'\$.FZL') like '%E%',null,
+                            json_extract(data,'\$.FZL')) as double)) over 
(partition by ordernum order by dnt desc) fzl,
+                            cast(if(json_extract(data,'\$.DB1')=0 or 
json_extract(data,'\$.DB1') like '%E%',null,json_extract(data,'\$.DB1')) as 
double) db1
+                    from test_table_aaa
+                        )a1
+                group by ordernum
+                )tmp left join (
+                select
+                    ordernum,MAX(p0) p0,MAX(j0) j0,MAX(g0) g0
+                from test_table_bbb
+                    group by ordernum
+                )tmp1
+                on tmp.ordernum=tmp1.ordernum;"""
 }


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

Reply via email to