You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/11/02 13:43:05 UTC
(doris) branch branch-2.0 updated: [Pick](inverted index) fix empty array index writer bug #25984 (#26297)
This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 0d925326d6f [Pick](inverted index) fix empty array index writer bug #25984 (#26297)
0d925326d6f is described below
commit 0d925326d6f1d046592b1fe591b3cf9c859cf105
Author: airborne12 <ai...@gmail.com>
AuthorDate: Thu Nov 2 21:42:56 2023 +0800
[Pick](inverted index) fix empty array index writer bug #25984 (#26297)
---
be/src/olap/rowset/segment_v2/column_writer.cpp | 23 +++++------
.../data/inverted_index_p0/test_index_null.out | 5 +++
.../inverted_index_p0/test_index_null.groovy | 48 ++++++++++++++++++++++
3 files changed, 64 insertions(+), 12 deletions(-)
diff --git a/be/src/olap/rowset/segment_v2/column_writer.cpp b/be/src/olap/rowset/segment_v2/column_writer.cpp
index 7a446f11235..8696aafb7e3 100644
--- a/be/src/olap/rowset/segment_v2/column_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/column_writer.cpp
@@ -950,21 +950,20 @@ Status ArrayColumnWriter::append_data(const uint8_t** ptr, size_t num_rows) {
size_t element_cnt = size_t((unsigned long)(*data_ptr));
auto offset_data = *(data_ptr + 1);
const uint8_t* offsets_ptr = (const uint8_t*)offset_data;
-
+ auto data = *(data_ptr + 2);
+ auto nested_null_map = *(data_ptr + 3);
if (element_cnt > 0) {
- auto data = *(data_ptr + 2);
- auto nested_null_map = *(data_ptr + 3);
RETURN_IF_ERROR(_item_writer->append(reinterpret_cast<const uint8_t*>(nested_null_map),
reinterpret_cast<const void*>(data), element_cnt));
- if (_opts.inverted_index) {
- auto writer = dynamic_cast<ScalarColumnWriter*>(_item_writer.get());
- // now only support nested type is scala
- if (writer != nullptr) {
- //NOTE: use array field name as index field, but item_writer size should be used when moving item_data_ptr
- _inverted_index_builder->add_array_values(
- _item_writer->get_field()->size(), reinterpret_cast<const void*>(data),
- reinterpret_cast<const uint8_t*>(nested_null_map), offsets_ptr, num_rows);
- }
+ }
+ if (_opts.inverted_index) {
+ auto writer = dynamic_cast<ScalarColumnWriter*>(_item_writer.get());
+ // now only support nested type is scala
+ if (writer != nullptr) {
+ //NOTE: use array field name as index field, but item_writer size should be used when moving item_data_ptr
+ RETURN_IF_ERROR(_inverted_index_builder->add_array_values(
+ _item_writer->get_field()->size(), reinterpret_cast<const void*>(data),
+ reinterpret_cast<const uint8_t*>(nested_null_map), offsets_ptr, num_rows));
}
}
diff --git a/regression-test/data/inverted_index_p0/test_index_null.out b/regression-test/data/inverted_index_p0/test_index_null.out
new file mode 100644
index 00000000000..29f296cab8b
--- /dev/null
+++ b/regression-test/data/inverted_index_p0/test_index_null.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql --
+
+-- !sql --
+
diff --git a/regression-test/suites/inverted_index_p0/test_index_null.groovy b/regression-test/suites/inverted_index_p0/test_index_null.groovy
new file mode 100644
index 00000000000..ef611496610
--- /dev/null
+++ b/regression-test/suites/inverted_index_p0/test_index_null.groovy
@@ -0,0 +1,48 @@
+// 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__null_index", "inverted_index"){
+ // prepare test table
+
+
+ def timeout = 60000
+ def delta_time = 1000
+ def alter_res = "null"
+ def useTime = 0
+
+ def indexTblName = "null_index_test"
+
+ sql "DROP TABLE IF EXISTS ${indexTblName}"
+ // create 1 replica table
+ sql """
+ CREATE TABLE IF NOT EXISTS ${indexTblName}(
+ `id` int(11) NOT NULL,
+ `value` array<text> NULL DEFAULT "[]",
+ INDEX c_value_idx(`value`) USING INVERTED PROPERTIES("parser" = "english") COMMENT ''
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`id`)
+ COMMENT 'OLAP'
+ DISTRIBUTED BY HASH(`id`) BUCKETS 1
+ PROPERTIES(
+ "replication_allocation" = "tag.location.default: 1"
+ );
+ """
+
+ sql "INSERT INTO $indexTblName VALUES (1, []), (2, []), (3, []);"
+ qt_sql "SELECT * FROM $indexTblName WHERE value match_all 'a';"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org