This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 2671c085e41 [branch-4.0](variant) Fix compaction failure on no-key
table with variant column uid=0 (#62656)
2671c085e41 is described below
commit 2671c085e41db57c68d59fe5fd4fb80dd0d4915d
Author: Chenyang Sun <[email protected]>
AuthorDate: Fri May 1 23:34:13 2026 +0800
[branch-4.0](variant) Fix compaction failure on no-key table with variant
column uid=0 (#62656)
pick from master #62571 #62632
---
.../rowset/segment_v2/variant_stats_calculator.cpp | 4 +-
be/src/olap/tablet_schema.h | 2 +-
be/src/vec/common/schema_util.cpp | 2 +-
.../compaction/test_compaction_nokey_variant.out | 21 +++++++
.../test_compaction_nokey_variant.groovy | 71 ++++++++++++++++++++++
5 files changed, 96 insertions(+), 4 deletions(-)
diff --git a/be/src/olap/rowset/segment_v2/variant_stats_calculator.cpp
b/be/src/olap/rowset/segment_v2/variant_stats_calculator.cpp
index 2b67ffc78c5..70722ca8748 100644
--- a/be/src/olap/rowset/segment_v2/variant_stats_calculator.cpp
+++ b/be/src/olap/rowset/segment_v2/variant_stats_calculator.cpp
@@ -37,7 +37,7 @@ VariantStatsCaculator::VariantStatsCaculator(SegmentFooterPB*
footer,
const auto& column = _footer->columns(i);
// path that need to record stats
if (column.has_column_path_info() &&
- column.column_path_info().parrent_column_unique_id() > 0) {
+ column.column_path_info().has_parrent_column_unique_id()) {
_path_to_footer_index[column.column_path_info().parrent_column_unique_id()]
[column.column_path_info().path()] = i;
}
@@ -50,7 +50,7 @@ Status VariantStatsCaculator::calculate_variant_stats(const
vectorized::Block* b
const TabletColumn& tablet_column =
_tablet_schema->column(_column_ids[i]);
// Only process sub columns and sparse columns during compaction
if (tablet_column.has_path_info() &&
tablet_column.path_info_ptr()->need_record_stats() &&
- tablet_column.parent_unique_id() > 0) {
+ tablet_column.parent_unique_id() >= 0) {
const std::string& column_path =
tablet_column.path_info_ptr()->get_path();
// Find the parent column in footer
auto it =
_path_to_footer_index.find(tablet_column.parent_unique_id());
diff --git a/be/src/olap/tablet_schema.h b/be/src/olap/tablet_schema.h
index 4ec777a84fa..a0869be3adc 100644
--- a/be/src/olap/tablet_schema.h
+++ b/be/src/olap/tablet_schema.h
@@ -179,7 +179,7 @@ public:
const vectorized::PathInDataPtr& path_info_ptr() const { return
_column_path; }
// If it is an extracted column from variant column
bool is_extracted_column() const {
- return _column_path != nullptr && !_column_path->empty() &&
_parent_col_unique_id > 0;
+ return _column_path != nullptr && !_column_path->empty() &&
_parent_col_unique_id >= 0;
};
std::string suffix_path() const {
return is_extracted_column() ? _column_path->get_path() : "";
diff --git a/be/src/vec/common/schema_util.cpp
b/be/src/vec/common/schema_util.cpp
index 7f49dc1dd02..91345712e62 100644
--- a/be/src/vec/common/schema_util.cpp
+++ b/be/src/vec/common/schema_util.cpp
@@ -377,7 +377,7 @@ Status update_least_common_schema(const
std::vector<TabletSchemaSPtr>& schemas,
for (const TabletSchemaSPtr& schema : schemas) {
for (const TabletColumnPtr& col : schema->columns()) {
// Get subcolumns of this variant
- if (col->has_path_info() && col->parent_unique_id() > 0 &&
+ if (col->has_path_info() && col->parent_unique_id() >= 0 &&
col->parent_unique_id() == variant_col_unique_id) {
subcolumns_types[*col->path_info_ptr()].emplace_back(
DataTypeFactory::instance().create_data_type(*col,
col->is_nullable()));
diff --git
a/regression-test/data/variant_p0/compaction/test_compaction_nokey_variant.out
b/regression-test/data/variant_p0/compaction/test_compaction_nokey_variant.out
new file mode 100644
index 00000000000..dade1e5e11a
--- /dev/null
+++
b/regression-test/data/variant_p0/compaction/test_compaction_nokey_variant.out
@@ -0,0 +1,21 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !before_compaction --
+{"age":10,"name":"u1"} {"city":"c1"} {"score":10.5}
+{"age":20,"name":"u2"} {"city":"c2"} {"score":20.5}
+{"age":25,"name":"Bob"} {"city":"Shanghai"} {"passed":1,"score":88}
+{"age":30,"name":"Alice"} {"city":"Beijing","zip":100000}
{"passed":1,"score":95.5}
+{"age":30,"name":"u3"} {"city":"c3"} {"score":30.5}
+{"age":40,"name":"u4"} {"city":"c4"} {"score":40.5}
+{"age":50,"name":"u5"} {"city":"c5"} {"score":50.5}
+{"name":"Charlie"} {"city":"Shenzhen","zip":518000}
{"passed":0,"score":72.3}
+
+-- !after_compaction --
+{"age":10,"name":"u1"} {"city":"c1"} {"score":10.5}
+{"age":20,"name":"u2"} {"city":"c2"} {"score":20.5}
+{"age":25,"name":"Bob"} {"city":"Shanghai"} {"passed":1,"score":88}
+{"age":30,"name":"Alice"} {"city":"Beijing","zip":100000}
{"passed":1,"score":95.5}
+{"age":30,"name":"u3"} {"city":"c3"} {"score":30.5}
+{"age":40,"name":"u4"} {"city":"c4"} {"score":40.5}
+{"age":50,"name":"u5"} {"city":"c5"} {"score":50.5}
+{"name":"Charlie"} {"city":"Shenzhen","zip":518000}
{"passed":0,"score":72.3}
+
diff --git
a/regression-test/suites/variant_p0/compaction/test_compaction_nokey_variant.groovy
b/regression-test/suites/variant_p0/compaction/test_compaction_nokey_variant.groovy
new file mode 100644
index 00000000000..5225ce11186
--- /dev/null
+++
b/regression-test/suites/variant_p0/compaction/test_compaction_nokey_variant.groovy
@@ -0,0 +1,71 @@
+// 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.
+
+// Regression test for: compaction fails on no-key duplicate table with only
+// variant columns when the first variant column has unique_id=0.
+// Root cause: TabletColumn::is_extracted_column() used "_parent_col_unique_id
> 0"
+// which incorrectly excluded subcolumns whose parent has unique_id=0.
+
+suite("test_compaction_nokey_variant") {
+ def tableName = "test_compaction_nokey_variant"
+
+ sql "DROP TABLE IF EXISTS ${tableName}"
+ sql """
+ CREATE TABLE ${tableName} (
+ v1 VARIANT,
+ v2 VARIANT,
+ v3 VARIANT
+ )
+ DISTRIBUTED BY RANDOM BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1",
+ "disable_auto_compaction" = "true",
+ "enable_duplicate_without_keys_by_default" = "true"
+ );
+ """
+
+ // Insert multiple batches to create multiple rowsets
+ sql """INSERT INTO ${tableName} VALUES
+ ('{"name":"Alice","age":30}', '{"city":"Beijing","zip":100000}',
'{"score":95.5,"passed":true}'),
+ ('{"name":"Bob","age":25}', '{"city":"Shanghai"}',
'{"score":88.0,"passed":true}'),
+ ('{"name":"Charlie"}', '{"city":"Shenzhen","zip":518000}',
'{"score":72.3,"passed":false}');"""
+
+ sql """INSERT INTO ${tableName} VALUES ('{"name":"u1","age":10}',
'{"city":"c1"}', '{"score":10.5}');"""
+ sql """INSERT INTO ${tableName} VALUES ('{"name":"u2","age":20}',
'{"city":"c2"}', '{"score":20.5}');"""
+ sql """INSERT INTO ${tableName} VALUES ('{"name":"u3","age":30}',
'{"city":"c3"}', '{"score":30.5}');"""
+ sql """INSERT INTO ${tableName} VALUES ('{"name":"u4","age":40}',
'{"city":"c4"}', '{"score":40.5}');"""
+ sql """INSERT INTO ${tableName} VALUES ('{"name":"u5","age":50}',
'{"city":"c5"}', '{"score":50.5}');"""
+
+ // Verify data before compaction
+ qt_before_compaction """SELECT cast(v1 as string) c1, cast(v2 as string)
c2, cast(v3 as string) c3
+ FROM ${tableName} ORDER BY c1;"""
+
+ def rowCountBefore = sql "SELECT count() FROM ${tableName}"
+ assertEquals(8, rowCountBefore[0][0])
+
+ // Trigger cumulative compaction - reproduces the bug when
is_extracted_column() is wrong
+ trigger_and_wait_compaction(tableName, "cumulative")
+
+ // Verify data after compaction
+ qt_after_compaction """SELECT cast(v1 as string) c1, cast(v2 as string)
c2, cast(v3 as string) c3
+ FROM ${tableName} ORDER BY c1;"""
+
+ def rowCountAfter = sql "SELECT count() FROM ${tableName}"
+ assertEquals(8, rowCountAfter[0][0])
+
+ sql "DROP TABLE IF EXISTS ${tableName}"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]