You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by he...@apache.org on 2026/05/11 02:08:29 UTC
(doris) branch master updated: [refine](Field) rename Tuple to Struct in BE core types (#63093)
This is an automated email from the ASF dual-hosted git repository.
hello-stephen 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 694c94f65f5 [refine](Field) rename Tuple to Struct in BE core types (#63093)
694c94f65f5 is described below
commit 694c94f65f526793cac7df2cfca506cb8539c8c1
Author: Mryange <ya...@selectdb.com>
AuthorDate: Mon May 11 10:08:22 2026 +0800
[refine](Field) rename Tuple to Struct in BE core types (#63093)
What problem does this PR solve?
Issue Number: N/A
Problem Summary:
The C++ struct Tuple in be/src/core/field.h is a type alias for
FieldVector used to represent STRUCT-typed field values. However, the
name "Tuple"
is misleading — this type corresponds to the STRUCT data type, not a
tuple. This rename aligns the C++ type name with the actual semantic:
Tuple
→ Struct, along with all references in comments, error messages, and
variable names.
---
be/src/core/column/column_struct.cpp | 13 +++++++------
be/src/core/data_type/convert_field_to_type.cpp | 2 +-
be/src/core/data_type/data_type.h | 2 +-
be/src/core/data_type/data_type_struct.cpp | 4 ++--
be/src/core/data_type/primitive_type.h | 4 ++--
be/src/core/field.h | 8 ++++----
be/src/exprs/vstruct_literal.cpp | 2 +-
be/src/util/json/json_parser.cpp | 4 ++--
be/test/core/column/column_hash_func_test.cpp | 2 +-
be/test/core/column/column_variant_test.cpp | 4 ++--
be/test/core/data_type/data_type_ip_test.cpp | 2 +-
be/test/core/data_type/data_type_map_test.cpp | 2 +-
be/test/core/data_type/data_type_struct_test.cpp | 10 +++++-----
be/test/core/data_type_serde/data_type_serde_arrow_test.cpp | 2 +-
be/test/core/data_type_serde/data_type_serde_pb_test.cpp | 4 ++--
be/test/core/data_type_serde/data_type_to_string_test.cpp | 2 +-
be/test/core/jsonb/convert_field_to_type_test.cpp | 2 +-
be/test/core/jsonb/serialize_test.cpp | 2 +-
18 files changed, 36 insertions(+), 35 deletions(-)
diff --git a/be/src/core/column/column_struct.cpp b/be/src/core/column/column_struct.cpp
index 5ddce06d19c..5cf8f390634 100644
--- a/be/src/core/column/column_struct.cpp
+++ b/be/src/core/column/column_struct.cpp
@@ -107,7 +107,7 @@ Field ColumnStruct::operator[](size_t n) const {
void ColumnStruct::get(size_t n, Field& res) const {
const size_t tuple_size = columns.size();
- res = Field::create_field<TYPE_STRUCT>(Tuple());
+ res = Field::create_field<TYPE_STRUCT>(Struct());
auto& res_tuple = res.get<TYPE_STRUCT>();
res_tuple.reserve(tuple_size);
@@ -121,10 +121,11 @@ void ColumnStruct::insert(const Field& x) {
const auto& tuple = x.get<TYPE_STRUCT>();
const size_t tuple_size = columns.size();
if (tuple.size() != tuple_size) {
- throw doris::Exception(ErrorCode::INTERNAL_ERROR,
- "Cannot insert value of different size into tuple. field tuple size "
- "{}, columns size {}",
- tuple.size(), tuple_size);
+ throw doris::Exception(
+ ErrorCode::INTERNAL_ERROR,
+ "Cannot insert value of different size into struct. field struct size "
+ "{}, columns size {}",
+ tuple.size(), tuple_size);
}
for (size_t i = 0; i < tuple_size; ++i) {
@@ -138,7 +139,7 @@ void ColumnStruct::insert_from(const IColumn& src_, size_t n) {
const size_t tuple_size = columns.size();
if (src.columns.size() != tuple_size) {
throw doris::Exception(ErrorCode::INTERNAL_ERROR,
- "Cannot insert value of different size into tuple.");
+ "Cannot insert value of different size into struct.");
__builtin_unreachable();
}
diff --git a/be/src/core/data_type/convert_field_to_type.cpp b/be/src/core/data_type/convert_field_to_type.cpp
index 5c6a94343df..8873c09346b 100644
--- a/be/src/core/data_type/convert_field_to_type.cpp
+++ b/be/src/core/data_type/convert_field_to_type.cpp
@@ -215,7 +215,7 @@ public:
}
void operator()(const Array& x, JsonbWriter* writer) const;
- void operator()(const Tuple& x, JsonbWriter* writer) const {
+ void operator()(const Struct& x, JsonbWriter* writer) const {
throw doris::Exception(doris::ErrorCode::NOT_IMPLEMENTED_ERROR, "Not implemeted");
}
void operator()(const Decimal32& x, JsonbWriter* writer) const {
diff --git a/be/src/core/data_type/data_type.h b/be/src/core/data_type/data_type.h
index 8d73c9036b1..9fb341302c0 100644
--- a/be/src/core/data_type/data_type.h
+++ b/be/src/core/data_type/data_type.h
@@ -131,7 +131,7 @@ public:
virtual bool equals_ignore_precision(const IDataType& rhs) const { return equals(rhs); }
- /** Example: numbers, Date, DateTime, FixedString, Enum... Nullable and Tuple of such types.
+ /** Example: numbers, Date, DateTime, FixedString, Enum... Nullable and Struct of such types.
* Counterexamples: String, Array.
* It's Ok to return false for AggregateFunction despite the fact that some of them have fixed size state.
*/
diff --git a/be/src/core/data_type/data_type_struct.cpp b/be/src/core/data_type/data_type_struct.cpp
index 0770899d661..44cdadd3e98 100644
--- a/be/src/core/data_type/data_type_struct.cpp
+++ b/be/src/core/data_type/data_type_struct.cpp
@@ -61,11 +61,11 @@ static Status check_tuple_names(const Strings& names) {
std::unordered_set<String> names_set;
for (const auto& name : names) {
if (name.empty()) {
- return Status::InvalidArgument("Names of tuple elements cannot be empty");
+ return Status::InvalidArgument("Names of struct elements cannot be empty");
}
if (!names_set.insert(name).second) {
- return Status::InvalidArgument("Names of tuple elements must be unique");
+ return Status::InvalidArgument("Names of struct elements must be unique");
}
}
diff --git a/be/src/core/data_type/primitive_type.h b/be/src/core/data_type/primitive_type.h
index 4fefb70860b..d7372ee431b 100644
--- a/be/src/core/data_type/primitive_type.h
+++ b/be/src/core/data_type/primitive_type.h
@@ -47,7 +47,7 @@ class ColumnVarbinary;
using ColumnString = ColumnStr<UInt32>;
class JsonbField;
struct Array;
-struct Tuple;
+struct Struct;
struct Map;
struct FieldWithDataType;
using VariantMap = std::map<PathInData, FieldWithDataType>;
@@ -487,7 +487,7 @@ struct PrimitiveTypeTraits<TYPE_MAP> {
};
template <>
struct PrimitiveTypeTraits<TYPE_STRUCT> {
- using CppType = Tuple;
+ using CppType = Struct;
using StorageFieldType = CppType;
using DataType = DataTypeStruct;
using ColumnType = ColumnStruct;
diff --git a/be/src/core/field.h b/be/src/core/field.h
index aff03a7f4fb..1bb4160d0dd 100644
--- a/be/src/core/field.h
+++ b/be/src/core/field.h
@@ -58,16 +58,16 @@ class Field;
using FieldVector = std::vector<Field>;
-/// Array and Tuple use the same storage type -- FieldVector, but we declare
+/// Array and Struct use the same storage type -- FieldVector, but we declare
/// distinct types for them, so that the caller can choose whether it wants to
-/// construct a Field of Array or a Tuple type. An alternative approach would be
+/// construct a Field of Array or a Struct type. An alternative approach would be
/// to construct both of these types from FieldVector, and have the caller
/// specify the desired Field type explicitly.
struct Array : public FieldVector {
using FieldVector::FieldVector;
};
-struct Tuple : public FieldVector {
+struct Struct : public FieldVector {
using FieldVector::FieldVector;
};
@@ -286,7 +286,7 @@ public:
private:
std::aligned_union_t<DBMS_MIN_FIELD_SIZE - sizeof(PrimitiveType), Null, UInt64, UInt128, Int64,
- Int128, IPv6, Float64, String, JsonbField, StringView, Array, Tuple, Map,
+ Int128, IPv6, Float64, String, JsonbField, StringView, Array, Struct, Map,
VariantMap, Decimal32, Decimal64, DecimalV2Value, Decimal128V3, Decimal256,
BitmapValue, HyperLogLog, QuantileState>
storage;
diff --git a/be/src/exprs/vstruct_literal.cpp b/be/src/exprs/vstruct_literal.cpp
index e405b37bfcd..05f9a09aeb7 100644
--- a/be/src/exprs/vstruct_literal.cpp
+++ b/be/src/exprs/vstruct_literal.cpp
@@ -36,7 +36,7 @@ namespace doris {
Status VStructLiteral::prepare(RuntimeState* state, const RowDescriptor& row_desc,
VExprContext* context) {
RETURN_IF_ERROR_OR_PREPARED(VExpr::prepare(state, row_desc, context));
- Field struct_field = Field::create_field<TYPE_STRUCT>(Tuple());
+ Field struct_field = Field::create_field<TYPE_STRUCT>(Struct());
for (const auto& child : _children) {
Field item;
auto child_literal = std::dynamic_pointer_cast<const VLiteral>(child);
diff --git a/be/src/util/json/json_parser.cpp b/be/src/util/json/json_parser.cpp
index 88142580346..2a7c401b9d8 100644
--- a/be/src/util/json/json_parser.cpp
+++ b/be/src/util/json/json_parser.cpp
@@ -369,9 +369,9 @@ StringRef JSONDataParser<ParserImpl>::getNameOfNested(const PathInData::Parts& p
return {};
}
/// Find first key that is marked as nested,
- /// because we may have tuple of Nested and there could be
+ /// because we may have struct of Nested and there could be
/// several arrays with the same prefix, but with independent sizes.
- /// Consider we have array element with type `k2 Tuple(k3 Nested(...), k5 Nested(...))`
+ /// Consider we have array element with type `k2 Struct(k3 Nested(...), k5 Nested(...))`
/// Then subcolumns `k2.k3` and `k2.k5` may have indepented sizes and we should extract
/// `k3` and `k5` keys instead of `k2`.
for (const auto& part : path) {
diff --git a/be/test/core/column/column_hash_func_test.cpp b/be/test/core/column/column_hash_func_test.cpp
index aa1e153111f..56cbde9e2df 100644
--- a/be/test/core/column/column_hash_func_test.cpp
+++ b/be/test/core/column/column_hash_func_test.cpp
@@ -239,7 +239,7 @@ TEST(HashFuncTest, StructTypeTestWithSepcificValueCrcHash) {
dataTypes.push_back(n1);
dataTypes.push_back(s1);
- Tuple t;
+ Struct t;
t.push_back(Field::create_field<TYPE_BIGINT>(Int64(1)));
t.push_back(Field::create_field<TYPE_STRING>("hello"));
diff --git a/be/test/core/column/column_variant_test.cpp b/be/test/core/column/column_variant_test.cpp
index 4e11ef80015..ebf59b77345 100644
--- a/be/test/core/column/column_variant_test.cpp
+++ b/be/test/core/column/column_variant_test.cpp
@@ -2767,9 +2767,9 @@ TEST_F(ColumnVariantTest, get_field_info_all_types) {
EXPECT_EQ(info.scalar_type_id, PrimitiveType::TYPE_JSONB);
}
- // Test Tuple
+ // Test Struct
{
- Tuple t1;
+ Struct t1;
t1.push_back(Field::create_field<TYPE_STRING>(String("amory cute")));
t1.push_back(Field::create_field<TYPE_BIGINT>(Int64(37)));
t1.push_back(Field::create_field<TYPE_BOOLEAN>(true));
diff --git a/be/test/core/data_type/data_type_ip_test.cpp b/be/test/core/data_type/data_type_ip_test.cpp
index b538c50adcc..d6aa58bcc33 100644
--- a/be/test/core/data_type/data_type_ip_test.cpp
+++ b/be/test/core/data_type/data_type_ip_test.cpp
@@ -290,7 +290,7 @@ TEST_F(DataTypeIPTest, SerdeTOJsonInComplex) {
column_map_ipv6->insert(Field::create_field<TYPE_MAP>(ipv6_map));
// pack struct
- Tuple tuple;
+ Struct tuple;
tuple.push_back(Field::create_field<TYPE_IPV4>(ipv4_values[0]));
tuple.push_back(Field::create_field<TYPE_IPV6>(ipv6_values[0]));
tuple.push_back(Field::create_field<TYPE_ARRAY>(ipv4_array));
diff --git a/be/test/core/data_type/data_type_map_test.cpp b/be/test/core/data_type/data_type_map_test.cpp
index 2bd87551085..a5633493c28 100644
--- a/be/test/core/data_type/data_type_map_test.cpp
+++ b/be/test/core/data_type/data_type_map_test.cpp
@@ -439,7 +439,7 @@ TEST_F(DataTypeMapTest, SerdeNestedTypeArrowTest) {
std::make_shared<DataTypeStruct>(std::vector<DataTypePtr> {f4}));
DataTypePtr ma = std::make_shared<DataTypeMap>(dt1, dt2);
- Tuple t1, t2, t3, t4;
+ Struct t1, t2, t3, t4;
t1.push_back(Field::create_field<TYPE_STRING>("clever"));
t1.push_back(Field::create_field<TYPE_LARGEINT>(__int128_t(37)));
t1.push_back(Field::create_field<TYPE_BOOLEAN>(true));
diff --git a/be/test/core/data_type/data_type_struct_test.cpp b/be/test/core/data_type/data_type_struct_test.cpp
index 60f473ee569..29006c7134e 100644
--- a/be/test/core/data_type/data_type_struct_test.cpp
+++ b/be/test/core/data_type/data_type_struct_test.cpp
@@ -388,7 +388,7 @@ TEST_F(DataTypeStructTest, SerdeNestedTypeArrowTest) {
m2.push_back(Field::create_field<TYPE_ARRAY>(v2));
// nested Struct
- Tuple t1, t2;
+ Struct t1, t2;
t1.push_back(Field::create_field<TYPE_STRING>("clever"));
t1.push_back(Field::create_field<TYPE_LARGEINT>(__int128_t(37)));
t1.push_back(Field::create_field<TYPE_BOOLEAN>(true));
@@ -397,7 +397,7 @@ TEST_F(DataTypeStructTest, SerdeNestedTypeArrowTest) {
t2.push_back(Field::create_field<TYPE_BOOLEAN>(false));
// Struct
- Tuple tt1, tt2;
+ Struct tt1, tt2;
tt1.push_back(Field::create_field<TYPE_ARRAY>(a1));
tt1.push_back(Field::create_field<TYPE_MAP>(m1));
tt1.push_back(Field::create_field<TYPE_STRUCT>(t1));
@@ -425,7 +425,7 @@ TEST_F(DataTypeStructTest, writeColumnToOrc) {
DataTypePtr st = std::make_shared<DataTypeStruct>(std::vector<DataTypePtr> {dt1, dt2});
auto serde = st->get_serde(1);
- Tuple test_data;
+ Struct test_data;
test_data.push_back(Field::create_field<TYPE_BIGINT>(100));
test_data.push_back(Field::create_field<TYPE_BIGINT>(200));
@@ -468,7 +468,7 @@ TEST_F(DataTypeStructTest, formString) {
DataTypePtr dt1 = std::make_shared<DataTypeInt32>();
DataTypePtr dt2 = std::make_shared<DataTypeString>();
DataTypePtr st = std::make_shared<DataTypeStruct>(std::vector<DataTypePtr> {dt1, dt2});
- Tuple tt1;
+ Struct tt1;
tt1.push_back(Field::create_field<TYPE_INT>(100));
tt1.push_back(Field::create_field<TYPE_STRING>("asd"));
@@ -500,7 +500,7 @@ TEST_F(DataTypeStructTest, insertColumnLastValueMultipleTimes) {
DataTypePtr dt1 = std::make_shared<DataTypeInt32>();
DataTypePtr dt2 = std::make_shared<DataTypeString>();
DataTypePtr st = std::make_shared<DataTypeStruct>(std::vector<DataTypePtr> {dt1, dt2});
- Tuple tt1;
+ Struct tt1;
tt1.push_back(Field::create_field<TYPE_INT>(100));
tt1.push_back(Field::create_field<TYPE_STRING>("asd"));
diff --git a/be/test/core/data_type_serde/data_type_serde_arrow_test.cpp b/be/test/core/data_type_serde/data_type_serde_arrow_test.cpp
index 602eb9f6975..63a3819cd35 100644
--- a/be/test/core/data_type_serde/data_type_serde_arrow_test.cpp
+++ b/be/test/core/data_type_serde/data_type_serde_arrow_test.cpp
@@ -358,7 +358,7 @@ std::shared_ptr<Block> create_test_block(std::vector<PrimitiveType> cols, int ro
DataTypePtr m = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>());
DataTypePtr st = std::make_shared<DataTypeStruct>(std::vector<DataTypePtr> {s, d, m});
type_desc = st;
- Tuple t1, t2;
+ Struct t1, t2;
t1.push_back(Field::create_field<TYPE_STRING>("amory cute"));
t1.push_back(Field::create_field<TYPE_LARGEINT>(__int128_t(37)));
t1.push_back(Field::create_field<TYPE_BOOLEAN>(true));
diff --git a/be/test/core/data_type_serde/data_type_serde_pb_test.cpp b/be/test/core/data_type_serde/data_type_serde_pb_test.cpp
index 8570d1d1637..986583982eb 100644
--- a/be/test/core/data_type_serde/data_type_serde_pb_test.cpp
+++ b/be/test/core/data_type_serde/data_type_serde_pb_test.cpp
@@ -547,7 +547,7 @@ TEST(DataTypeSerDePbTest, DataTypeScalaSerDeTestStruct) {
DataTypePtr d = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeInt128>());
DataTypePtr m = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>());
DataTypePtr st = std::make_shared<DataTypeStruct>(std::vector<DataTypePtr> {s, d, m});
- Tuple t1, t2;
+ Struct t1, t2;
t1.push_back(Field::create_field<TYPE_STRING>(String("amory cute")));
t1.push_back(Field::create_field<TYPE_LARGEINT>(__int128_t(37)));
t1.push_back(Field::create_field<TYPE_BOOLEAN>(true));
@@ -578,7 +578,7 @@ TEST(DataTypeSerDePbTest, DataTypeScalaSerDeTestStruct2) {
DataTypePtr d = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeInt64>());
DataTypePtr m = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>());
DataTypePtr st = std::make_shared<DataTypeStruct>(std::vector<DataTypePtr> {s, d, m});
- Tuple t1, t2;
+ Struct t1, t2;
t1.push_back(Field::create_field<TYPE_STRING>(String("amory cute")));
t1.push_back(Field::create_field<TYPE_BIGINT>(37));
t1.push_back(Field::create_field<TYPE_BOOLEAN>(true));
diff --git a/be/test/core/data_type_serde/data_type_to_string_test.cpp b/be/test/core/data_type_serde/data_type_to_string_test.cpp
index 106b8c9bffe..132d031e21d 100644
--- a/be/test/core/data_type_serde/data_type_to_string_test.cpp
+++ b/be/test/core/data_type_serde/data_type_to_string_test.cpp
@@ -54,7 +54,7 @@ TEST(ToStringMethodTest, DataTypeToStringTest) {
m.push_back(Field::create_field<TYPE_ARRAY>(a1));
m.push_back(Field::create_field<TYPE_ARRAY>(a2));
- Tuple t;
+ Struct t;
t.push_back(Field::create_field<TYPE_LARGEINT>(Int128(12345454342)));
t.push_back(Field::create_field<TYPE_STRING>(String("amory cute")));
t.push_back(Field::create_field<TYPE_BIGINT>(Int64(0)));
diff --git a/be/test/core/jsonb/convert_field_to_type_test.cpp b/be/test/core/jsonb/convert_field_to_type_test.cpp
index ac623dc7e84..921cb9693e5 100644
--- a/be/test/core/jsonb/convert_field_to_type_test.cpp
+++ b/be/test/core/jsonb/convert_field_to_type_test.cpp
@@ -502,7 +502,7 @@ TEST_F(ConvertFieldToTypeTest, ConvertFieldToType_ErrorCases) {
// Test with unsupported types (should throw exception)
{
- Field tuple_field = Field::create_field<TYPE_STRUCT>(Tuple());
+ Field tuple_field = Field::create_field<TYPE_STRUCT>(Struct());
EXPECT_THROW(
{
diff --git a/be/test/core/jsonb/serialize_test.cpp b/be/test/core/jsonb/serialize_test.cpp
index 27c8b3aed10..58aad7ca618 100644
--- a/be/test/core/jsonb/serialize_test.cpp
+++ b/be/test/core/jsonb/serialize_test.cpp
@@ -288,7 +288,7 @@ TEST(BlockSerializeTest, Struct) {
DataTypePtr d = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeInt128>());
DataTypePtr m = std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt8>());
DataTypePtr st = std::make_shared<DataTypeStruct>(std::vector<DataTypePtr> {s, d, m});
- Tuple t1, t2;
+ Struct t1, t2;
t1.push_back(Field::create_field<TYPE_STRING>(String("amory cute")));
t1.push_back(Field::create_field<TYPE_LARGEINT>(__int128_t(37)));
t1.push_back(Field::create_field<TYPE_BOOLEAN>(true));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org