This is an automated email from the ASF dual-hosted git repository. yiguolei 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 f7e3cc1553 [FIX](map)fix map proto contains_null #22107 f7e3cc1553 is described below commit f7e3cc1553de1fd74c2d6f21d0bbc4eb029067d8 Author: amory <wangqian...@selectdb.com> AuthorDate: Sat Jul 22 10:41:55 2023 +0800 [FIX](map)fix map proto contains_null #22107 when we select map in order by and limit; be node will coredump --- be/src/runtime/types.cpp | 7 ++++ gensrc/proto/types.proto | 2 + .../query_p0/limit/test_map_select_with_limit.out | 4 ++ .../limit/test_map_select_with_limit.groovy | 49 ++++++++++++++++++++++ 4 files changed, 62 insertions(+) diff --git a/be/src/runtime/types.cpp b/be/src/runtime/types.cpp index 8cbeebe4c3..4e5eca722b 100644 --- a/be/src/runtime/types.cpp +++ b/be/src/runtime/types.cpp @@ -199,6 +199,9 @@ void TypeDescriptor::to_protobuf(PTypeDesc* ptype) const { } } else if (type == TYPE_MAP) { node->set_type(TTypeNodeType::MAP); + DCHECK_EQ(2, contains_nulls.size()); + node->add_contains_nulls(contains_nulls[0]); + node->add_contains_nulls(contains_nulls[1]); for (const TypeDescriptor& child : children) { child.to_protobuf(ptype); } @@ -252,6 +255,10 @@ TypeDescriptor::TypeDescriptor(const google::protobuf::RepeatedPtrField<PTypeNod children.push_back(TypeDescriptor(types, idx)); ++(*idx); children.push_back(TypeDescriptor(types, idx)); + if (node.contains_nulls_size() > 1) { + contains_nulls.push_back(node.contains_nulls(0)); + contains_nulls.push_back(node.contains_nulls(1)); + } break; } case TTypeNodeType::STRUCT: { diff --git a/gensrc/proto/types.proto b/gensrc/proto/types.proto index af0f1fcc1d..0bc9f46fa1 100644 --- a/gensrc/proto/types.proto +++ b/gensrc/proto/types.proto @@ -51,6 +51,8 @@ message PTypeNode { repeated PStructField struct_fields = 3; // only used for complex types, such as array, map and etc. optional bool contains_null = 4; + // update for map/struct type + repeated bool contains_nulls = 5; }; // A flattened representation of a tree of column types obtained by depth-first diff --git a/regression-test/data/query_p0/limit/test_map_select_with_limit.out b/regression-test/data/query_p0/limit/test_map_select_with_limit.out new file mode 100644 index 0000000000..5625ea5d53 --- /dev/null +++ b/regression-test/data/query_p0/limit/test_map_select_with_limit.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +100 {1:"amory", 2:"is", 3:"better"} + diff --git a/regression-test/suites/query_p0/limit/test_map_select_with_limit.groovy b/regression-test/suites/query_p0/limit/test_map_select_with_limit.groovy new file mode 100644 index 0000000000..43d340fce9 --- /dev/null +++ b/regression-test/suites/query_p0/limit/test_map_select_with_limit.groovy @@ -0,0 +1,49 @@ +// 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_map_select_with_limit", "query") { + // define a sql table + def testTable = "test_map_select_with_limit" + + sql """ + CREATE TABLE IF NOT EXISTS ${testTable} ( + `k1` INT(11) NULL, + `k2` MAP<SMALLINT(6), STRING> NULL, + ) ENGINE=OLAP + DUPLICATE KEY(`k1`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`k1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "in_memory" = "false", + "storage_format" = "V2", + "disable_auto_compaction" = "false" + ) + """ + // prepare data + sql """ INSERT INTO ${testTable} VALUES (100, {1: "amory", 2: "is", 3: "better"}) """ + // set topn_opt_limit_threshold = 1024 to make sure _internal_service to be request with proto request + sql """ set topn_opt_limit_threshold = 1024 """ + + explain{ + sql("select * from ${testTable} order by k1 limit 1") + contains "TOPN" + } + + + qt_select """ select * from ${testTable} order by k1 limit 1 """ +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org