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 0aa1f4fd63c branch-4.0: [Fix](Variant) handle spase column type
correctly #57701 (#57705)
0aa1f4fd63c is described below
commit 0aa1f4fd63c334cdbef9e7e90271e83308543b85
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Nov 6 10:53:35 2025 +0800
branch-4.0: [Fix](Variant) handle spase column type correctly #57701
(#57705)
Cherry-picked from #57701
Co-authored-by: lihangyu <[email protected]>
---
be/src/olap/rowset/segment_v2/segment.cpp | 2 +-
be/test/vec/common/schema_util_rowset_test.cpp | 29 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/be/src/olap/rowset/segment_v2/segment.cpp
b/be/src/olap/rowset/segment_v2/segment.cpp
index 0675c357ccb..0e2f97a15da 100644
--- a/be/src/olap/rowset/segment_v2/segment.cpp
+++ b/be/src/olap/rowset/segment_v2/segment.cpp
@@ -622,7 +622,7 @@ vectorized::DataTypePtr Segment::get_data_type_of(const
TabletColumn& column,
// Find the specific node within the variant structure using the relative
path.
const auto* node =
variant_reader->get_subcolumn_meta_by_path(relative_path);
- if (relative_path.get_path() == SPARSE_COLUMN_PATH) {
+ if (relative_path.get_path().find(BeConsts::SPARSE_COLUMN_PATH) !=
std::string::npos) {
return
vectorized::DataTypeFactory::instance().create_data_type(column);
}
diff --git a/be/test/vec/common/schema_util_rowset_test.cpp
b/be/test/vec/common/schema_util_rowset_test.cpp
index 19aff440e0a..f453aeff8d9 100644
--- a/be/test/vec/common/schema_util_rowset_test.cpp
+++ b/be/test/vec/common/schema_util_rowset_test.cpp
@@ -18,6 +18,7 @@
#include <gmock/gmock-more-matchers.h>
#include <gtest/gtest.h>
+#include "common/consts.h"
#include "olap/rowset/beta_rowset_writer.h"
#include "olap/rowset/rowset_factory.h"
#include "olap/rowset/segment_v2/variant/variant_column_writer_impl.h"
@@ -438,6 +439,34 @@ TEST_F(SchemaUtilRowsetTest,
collect_path_stats_and_get_extended_compaction_sche
EXPECT_TRUE(data_type != nullptr);
EXPECT_TRUE(data_type->get_storage_field_type() ==
FieldType::OLAP_FIELD_TYPE_STRING);
+ // path contains sparse marker, should return default column type
(OLAP_FIELD_TYPE_MAP)
+ TabletColumn sparse_typed_col;
+ sparse_typed_col.set_name("v1.__DORIS_VARIANT_SPARSE__");
+ sparse_typed_col.set_type(FieldType::OLAP_FIELD_TYPE_MAP);
+ sparse_typed_col.set_unique_id(-1);
+ sparse_typed_col.set_parent_unique_id(1);
+ sparse_typed_col.set_path_info(PathInData(std::string("v1.") +
BeConsts::SPARSE_COLUMN_PATH));
+ sparse_typed_col.set_variant_max_subcolumns_count(3);
+ sparse_typed_col.set_is_nullable(true);
+ // add key/value subcolumns for MAP to satisfy DataTypeFactory checks
+ // key: STRING, value: VARIANT
+ {
+ TabletColumn key_col;
+ key_col.set_name("__key");
+ key_col.set_type(FieldType::OLAP_FIELD_TYPE_STRING);
+ key_col.set_is_nullable(false);
+ sparse_typed_col.add_sub_column(key_col);
+
+ TabletColumn value_col;
+ value_col.set_name("__value");
+ value_col.set_type(FieldType::OLAP_FIELD_TYPE_INT);
+ value_col.set_is_nullable(true);
+ sparse_typed_col.add_sub_column(value_col);
+ }
+ data_type = segment->get_data_type_of(sparse_typed_col, true);
+ EXPECT_TRUE(data_type != nullptr);
+ EXPECT_TRUE(data_type->get_storage_field_type() ==
FieldType::OLAP_FIELD_TYPE_MAP);
+
subcolumn_in_sparse.set_name("v1.keyb");
subcolumn_in_sparse.set_type(FieldType::OLAP_FIELD_TYPE_INT);
subcolumn_in_sparse.set_path_info(PathInData("v1.keyb"));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]