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 307170030c [Bug](materialized-view) fix core dump when create mv have 
case different with base table (#18206)
307170030c is described below

commit 307170030c8c0994ee5f5ee03adb1c8bb51e6f98
Author: Pxl <[email protected]>
AuthorDate: Fri Mar 31 12:32:09 2023 +0800

    [Bug](materialized-view) fix core dump when create mv have case different 
with base table (#18206)
    
    fix core dump when create mv have case different with base table
---
 be/src/olap/schema_change.cpp                      |  9 ++--
 be/src/vec/core/block.cpp                          |  2 +-
 be/src/vec/exprs/vslot_ref.cpp                     |  5 ++
 .../java/org/apache/doris/alter/RollupJobV2.java   |  3 +-
 .../java/org/apache/doris/analysis/InsertStmt.java |  2 +-
 .../data/mv_p0/case_ignore/case_ignore.out         | 19 ++++++++
 .../suites/mv_p0/case_ignore/case_ignore.groovy    | 57 ++++++++++++++++++++++
 7 files changed, 90 insertions(+), 7 deletions(-)

diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp
index d811ddb370..148696897c 100644
--- a/be/src/olap/schema_change.cpp
+++ b/be/src/olap/schema_change.cpp
@@ -270,10 +270,11 @@ Status BlockChanger::change_block(vectorized::Block* 
ref_block,
 
             int result_column_id = -1;
             RETURN_IF_ERROR(ctx->execute(ref_block, &result_column_id));
-            CHECK(ref_block->get_by_position(result_column_id).column->size() 
== row_size)
-                    << new_block->get_by_position(idx).name << " size invalid"
-                    << ", expect=" << row_size
-                    << ", real=" << 
ref_block->get_by_position(result_column_id).column->size();
+            if (ref_block->get_by_position(result_column_id).column->size() != 
row_size) {
+                return Status::Error<ErrorCode::INTERNAL_ERROR>(
+                        "{} size invalid, expect={}, real={}", 
new_block->get_by_position(idx).name,
+                        row_size, 
ref_block->get_by_position(result_column_id).column->size());
+            }
 
             if (_type != ROLLUP) {
                 RETURN_IF_ERROR(
diff --git a/be/src/vec/core/block.cpp b/be/src/vec/core/block.cpp
index aadf51946e..0625718767 100644
--- a/be/src/vec/core/block.cpp
+++ b/be/src/vec/core/block.cpp
@@ -494,7 +494,7 @@ std::string Block::dump_structure() const {
     std::string out;
     for (auto it = data.begin(); it != data.end(); ++it) {
         if (it != data.begin()) {
-            out += ", ";
+            out += ", \n";
         }
         out += it->dump_structure();
     }
diff --git a/be/src/vec/exprs/vslot_ref.cpp b/be/src/vec/exprs/vslot_ref.cpp
index 60c7f7fd52..a1ff659511 100644
--- a/be/src/vec/exprs/vslot_ref.cpp
+++ b/be/src/vec/exprs/vslot_ref.cpp
@@ -61,6 +61,11 @@ Status VSlotRef::prepare(doris::RuntimeState* state, const 
doris::RowDescriptor&
 }
 
 Status VSlotRef::execute(VExprContext* context, Block* block, int* 
result_column_id) {
+    if (_column_id >= 0 && _column_id >= block->columns()) {
+        return Status::Error<ErrorCode::INTERNAL_ERROR>(
+                "input block not contain slot column {}, column_id={}, 
block={}", *_column_name,
+                _column_id, block->dump_structure());
+    }
     *result_column_id = _column_id;
     return Status::OK();
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java 
b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
index 68cf0bd6f4..7e11dac3f6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
@@ -85,6 +85,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -384,7 +385,7 @@ public class RollupJobV2 extends AlterJobV2 implements 
GsonPostProcessable {
 
                     DescriptorTable descTable = new DescriptorTable();
                     TupleDescriptor destTupleDesc = 
descTable.createTupleDescriptor();
-                    Map<String, SlotDescriptor> descMap = Maps.newHashMap();
+                    Map<String, SlotDescriptor> descMap = new 
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
 
                     List<Column> rollupColumns = new ArrayList<Column>();
                     Set<String> columnNames = new HashSet<String>();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java
index 98cb6354bb..c9d3f409f7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java
@@ -505,7 +505,7 @@ public class InsertStmt extends DdlStmt {
         // Check if all columns mentioned is enough
         checkColumnCoverage(mentionedColumns, targetTable.getBaseSchema());
 
-        Map<String, Expr> slotToIndex = Maps.newTreeMap();
+        Map<String, Expr> slotToIndex = 
Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
         List<Column> baseColumns = targetTable.getBaseSchema();
         int size = Math.min(baseColumns.size(), 
queryStmt.getResultExprs().size());
         for (int i = 0; i < size; i++) {
diff --git a/regression-test/data/mv_p0/case_ignore/case_ignore.out 
b/regression-test/data/mv_p0/case_ignore/case_ignore.out
new file mode 100644
index 0000000000..46dbfd4eeb
--- /dev/null
+++ b/regression-test/data/mv_p0/case_ignore/case_ignore.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select_star --
+-4     -4      -4      d
+1      1       1       a
+2      2       2       b
+3      -3      \N      c
+
+-- !select_mv --
+-4     4
+1      1
+2      2
+3      3
+
+-- !select_mv --
+-4     4
+1      1
+2      2
+3      3
+
diff --git a/regression-test/suites/mv_p0/case_ignore/case_ignore.groovy 
b/regression-test/suites/mv_p0/case_ignore/case_ignore.groovy
new file mode 100644
index 0000000000..88f9a38578
--- /dev/null
+++ b/regression-test/suites/mv_p0/case_ignore/case_ignore.groovy
@@ -0,0 +1,57 @@
+// 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.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite ("case_ignore") {
+    sql """ DROP TABLE IF EXISTS d_table; """
+
+    sql """
+            create table d_table(
+                k1 int null,
+                k2 int not null,
+                k3 bigint null,
+                k4 varchar(100) null
+            )
+            duplicate key (k1,k2,k3)
+            distributed BY hash(k1) buckets 3
+            properties("replication_num" = "1");
+        """
+
+    sql "insert into d_table select 1,1,1,'a';"
+    sql "insert into d_table select 2,2,2,'b';"
+    sql "insert into d_table select 3,-3,null,'c';"
+
+    createMV ("create materialized view k12a as select K1,abs(K2) from 
d_table;")
+
+    sql "insert into d_table select -4,-4,-4,'d';"
+
+    qt_select_star "select * from d_table order by k1;"
+
+    explain {
+        sql("select k1,abs(k2) from d_table order by k1;")
+        contains "(k12a)"
+    }
+    qt_select_mv "select k1,abs(k2) from d_table order by k1;"
+
+    explain {
+        sql("select K1,abs(K2) from d_table order by K1;")
+        contains "(k12a)"
+    }
+    qt_select_mv "select K1,abs(K2) from d_table order by K1;"
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to