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 2024/07/15 07:48:30 UTC

(doris) branch cp_-715_2 created (now a8abd3bb452)

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

panxiaolei pushed a change to branch cp_-715_2
in repository https://gitbox.apache.org/repos/asf/doris.git


      at a8abd3bb452 [Bug](query) fix meet invalid column when direct scan on mow mv (#36483)

This branch includes the following new commits:

     new a8abd3bb452 [Bug](query) fix meet invalid column when direct scan on mow mv (#36483)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


(doris) 01/01: [Bug](query) fix meet invalid column when direct scan on mow mv (#36483)

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

panxiaolei pushed a commit to branch cp_-715_2
in repository https://gitbox.apache.org/repos/asf/doris.git

commit a8abd3bb4520f87f6943d32bc1b052093eb050be
Author: Pxl <px...@qq.com>
AuthorDate: Wed Jun 19 12:39:53 2024 +0800

    [Bug](query) fix meet invalid column when direct scan on mow mv (#36483)
    
    fix meet invalid column when direct scan on mow mv
    ```
    2024-06-11 18:01:14,079 [query] |Client=|User=root|Ctl=internal|Db=__internal_schema|State=OK|ErrorCode=0|ErrorMessage=|Time(ms)=3601|ScanBytes=57344|ScanRows=1|ReturnRows=0|StmtId=0|QueryId=67799c8ba77d4ffb-8a80c73b94bb784c|IsQuery=true|isNereids=true|feIp=10.16.10.8|Stmt=SELECT SUBSTRING(CAST(MIN(`mv_(k2 + k3)`) AS STRING), 1, 1024) as min, SUBSTRING(CAST(MAX(`mv_(k2 + k3)`) AS STRING), 1, 1024) as max FROM `regression_test_mv_p0_test_mv_mow`.`u_table` index `k123p`|CpuTimeMS=3544|S [...]
     2024-06-11 18:01:08,291 WARN (Analysis Job Executor-0|521) [Coordinator.getNext():1109] Query 67799c8ba77d4ffb-8a80c73b94bb784c coordinator get next fail, (hk2.dev.selectdb-in.cc)[INTERNAL_ERROR]SegmentIterator meet invalid column, id=1, name=mv_(k2 + k3), need cancel
    ```
---
 .../doris/nereids/rules/analysis/BindRelation.java | 10 ++---
 .../data/mv_p0/test_mv_mor/test_mv_mor.out         | 17 +++++++
 .../suites/mv_p0/test_mv_mor/test_mv_mor.groovy    | 52 ++++++++++++++++++++++
 3 files changed, 72 insertions(+), 7 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
index b76fe7c07ea..e6f550305e3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
@@ -18,7 +18,6 @@
 package org.apache.doris.nereids.rules.analysis;
 
 import org.apache.doris.catalog.Column;
-import org.apache.doris.catalog.KeysType;
 import org.apache.doris.catalog.OlapTable;
 import org.apache.doris.catalog.Partition;
 import org.apache.doris.catalog.TableIf;
@@ -202,10 +201,8 @@ public class BindRelation extends OneAnalysisRuleFactory {
                     throw new AnalysisException("Table " + olapTable.getName()
                         + " doesn't have materialized view " + indexName.get());
                 }
-                PreAggStatus preAggStatus
-                        = olapTable.getIndexMetaByIndexId(indexId).getKeysType().equals(KeysType.DUP_KEYS)
-                        ? PreAggStatus.unset()
-                        : PreAggStatus.off("For direct index scan.");
+                PreAggStatus preAggStatus = olapTable.isDupKeysOrMergeOnWrite() ? PreAggStatus.unset()
+                        : PreAggStatus.off("For direct index scan on mor/agg.");
 
                 scan = new LogicalOlapScan(unboundRelation.getRelationId(),
                     (OlapTable) table, qualifier, tabletIds,
@@ -219,8 +216,7 @@ public class BindRelation extends OneAnalysisRuleFactory {
             }
         }
         if (!Util.showHiddenColumns() && scan.getTable().hasDeleteSign()
-                && !ConnectContext.get().getSessionVariable().skipDeleteSign()
-                && !scan.isDirectMvScan()) {
+                && !ConnectContext.get().getSessionVariable().skipDeleteSign()) {
             // table qualifier is catalog.db.table, we make db.table.column
             Slot deleteSlot = null;
             for (Slot slot : scan.getOutput()) {
diff --git a/regression-test/data/mv_p0/test_mv_mor/test_mv_mor.out b/regression-test/data/mv_p0/test_mv_mor/test_mv_mor.out
new file mode 100644
index 00000000000..fbf59000daf
--- /dev/null
+++ b/regression-test/data/mv_p0/test_mv_mor/test_mv_mor.out
@@ -0,0 +1,17 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select_mv --
+1	2
+1	3
+
+-- !select_mv --
+1	2
+1	3
+
+-- !select_mv --
+1
+1
+
+-- !select_mv --
+2
+3
+
diff --git a/regression-test/suites/mv_p0/test_mv_mor/test_mv_mor.groovy b/regression-test/suites/mv_p0/test_mv_mor/test_mv_mor.groovy
new file mode 100644
index 00000000000..1ca52c75e86
--- /dev/null
+++ b/regression-test/suites/mv_p0/test_mv_mor/test_mv_mor.groovy
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite ("test_mv_mor") {
+    sql """ drop table if exists u_table; """
+
+    sql """
+            create table u_table (
+                k1 int null,
+                k2 int not null,
+                k3 bigint null,
+                k4 varchar(100) null
+            )
+            unique key (k1,k2,k3)
+            distributed BY hash(k1) buckets 3
+            properties(
+                "replication_num" = "1",
+                "enable_unique_key_merge_on_write" = "false"
+            );
+        """
+    sql "insert into u_table select 1,1,1,1;"
+    sql "insert into u_table select 1,2,1,1;"
+    createMV("create materialized view k123p as select k1,k2+k3 from u_table;")
+
+    sql "insert into u_table select 1,1,1,2;"
+    sql "insert into u_table select 1,2,1,2;"
+
+    // do not match mv coz preagg is off, mv need contains all key column to make row count correct
+    explain {
+        sql("select k1,k2+k3 from u_table order by k1;")
+        contains "(u_table)"
+    }
+    qt_select_mv "select k1,k2+k3 from u_table order by k1;"
+
+    qt_select_mv "select * from `u_table` index `k123p` order by 1,2;"
+    qt_select_mv "select mv_k1 from `u_table` index `k123p` order by 1;"
+    qt_select_mv "select `mv_(k2 + k3)` from `u_table` index `k123p` order by 1;"
+}


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