You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/01/13 06:13:54 UTC
[doris] 03/05: [fix](olap) dictionary cannot be sorted after inserting some null values (#15829)
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 915abc8c53414a6169f8018e4cac45cb38a1a9d1
Author: Jerry Hu <mr...@gmail.com>
AuthorDate: Fri Jan 13 09:28:55 2023 +0800
[fix](olap) dictionary cannot be sorted after inserting some null values (#15829)
---
be/src/vec/columns/column_dictionary.h | 6 +++
.../suites/query_p0/test_dict_with_null.groovy | 46 ++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/be/src/vec/columns/column_dictionary.h b/be/src/vec/columns/column_dictionary.h
index 422e2fdfbb..95cd848763 100644
--- a/be/src/vec/columns/column_dictionary.h
+++ b/be/src/vec/columns/column_dictionary.h
@@ -240,6 +240,12 @@ public:
}
void convert_dict_codes_if_necessary() override {
+ // Avoid setting `_dict_sorted` to true when `_dict` is empty.
+ // Because `_dict` maybe keep empty after inserting some null rows.
+ if (_dict.empty()) {
+ return;
+ }
+
if (!is_dict_sorted()) {
_dict.sort();
_dict_sorted = true;
diff --git a/regression-test/suites/query_p0/test_dict_with_null.groovy b/regression-test/suites/query_p0/test_dict_with_null.groovy
new file mode 100644
index 0000000000..a5c84444ae
--- /dev/null
+++ b/regression-test/suites/query_p0/test_dict_with_null.groovy
@@ -0,0 +1,46 @@
+// 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("dict_with_null", "query") {
+ def tableName = "test_dict_with_null"
+ sql "DROP TABLE IF EXISTS ${tableName}"
+ sql """
+ CREATE TABLE IF NOT EXISTS ${tableName} (
+ c_int INT,
+ c_string VARCHAR(10)
+ )
+ DISTRIBUTED BY HASH(c_int) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1"
+ )
+ """
+
+ // Here insert all rows in one statement to make sure they are in one same segment.
+ // Insert 100 + 1 rows because `SegmentIterator` will read 100 rows in the first time.
+ // The first 100 rows are all null to make no record be inserted into dictionary at the first read time.
+ def insert_sql = "insert into ${tableName} values "
+ for (int i in 1..100) {
+ if (i != 1) {
+ insert_sql += ", "
+ }
+ insert_sql += "(${i}, null)"
+ }
+ insert_sql += ", (101, 'abc')"
+
+ sql insert_sql
+ sql "select * from test_dict_with_null where c_string > '0'"
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org