You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by pa...@apache.org on 2023/04/07 03:11:25 UTC

[doris] branch master updated: [Bug](materialized-view) fix materialized-view query match not consider with order by elements (#18384)

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

panxiaolei 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 267b690dad [Bug](materialized-view) fix materialized-view query match not consider with order by elements (#18384)
267b690dad is described below

commit 267b690dadab4ff881811a039744fc8aa3dc9cae
Author: Pxl <px...@qq.com>
AuthorDate: Fri Apr 7 11:11:18 2023 +0800

    [Bug](materialized-view) fix materialized-view query match not consider with order by elements (#18384)
    
    fix materialized-view query match not consider with order by elements
---
 fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java  | 4 ++++
 regression-test/data/mv_p0/test_dup_mv_plus/test_dup_mv_plus.out    | 6 ++++++
 .../suites/mv_p0/test_dup_mv_plus/test_dup_mv_plus.groovy           | 6 ++++++
 3 files changed, 16 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 132168b182..90d69faf35 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
@@ -230,6 +230,10 @@ public class SelectStmt extends QueryStmt {
         if (havingClauseAfterAnaylzed != null) {
             exprs.add(havingClauseAfterAnaylzed);
         }
+        if (orderByElementsAfterAnalyzed != null) {
+            exprs.addAll(orderByElementsAfterAnalyzed.stream().map(orderByElement -> orderByElement.getExpr())
+                    .collect(Collectors.toList()));
+        }
         return exprs;
     }
 
diff --git a/regression-test/data/mv_p0/test_dup_mv_plus/test_dup_mv_plus.out b/regression-test/data/mv_p0/test_dup_mv_plus/test_dup_mv_plus.out
index 984f07c023..1e705fcc85 100644
--- a/regression-test/data/mv_p0/test_dup_mv_plus/test_dup_mv_plus.out
+++ b/regression-test/data/mv_p0/test_dup_mv_plus/test_dup_mv_plus.out
@@ -47,3 +47,9 @@
 1
 2
 
+-- !select_mv --
+-4	-3
+3	-2
+1	2
+2	3
+
diff --git a/regression-test/suites/mv_p0/test_dup_mv_plus/test_dup_mv_plus.groovy b/regression-test/suites/mv_p0/test_dup_mv_plus/test_dup_mv_plus.groovy
index eb919b28f6..2c3f403996 100644
--- a/regression-test/suites/mv_p0/test_dup_mv_plus/test_dup_mv_plus.groovy
+++ b/regression-test/suites/mv_p0/test_dup_mv_plus/test_dup_mv_plus.groovy
@@ -83,4 +83,10 @@ suite ("test_dup_mv_plus") {
         contains "(d_table)"
     }
     qt_select_group_mv_not "select sum(k2) from d_table group by k3 order by k3;"
+
+    explain {
+        sql("select k1,k2+1 from d_table order by k2;")
+        contains "(d_table)"
+    }
+    qt_select_mv "select k1,k2+1 from d_table order by k2;"
 }


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