github-actions[bot] commented on code in PR #65087:
URL: https://github.com/apache/doris/pull/65087#discussion_r3505094338


##########
be/test/core/column/column_mutate_subcolumns_test.cpp:
##########
@@ -0,0 +1,139 @@
+// 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.
+
+#include <gtest/gtest.h>
+
+#include "core/column/column_array.h"
+#include "core/column/column_const.h"
+#include "core/column/column_map.h"
+#include "core/column/column_nullable.h"
+#include "core/column/column_struct.h"
+#include "core/column/column_vector.h"
+
+namespace doris {
+namespace {
+
+ColumnInt64::MutablePtr create_int64_column(int64_t value) {
+    auto column = ColumnInt64::create();
+    column->insert_value(value);
+    return column;
+}
+
+ColumnUInt8::MutablePtr create_uint8_column(uint8_t value) {
+    auto column = ColumnUInt8::create();
+    column->insert_value(value);
+    return column;
+}
+
+ColumnArray::ColumnOffsets::MutablePtr create_single_element_offsets() {
+    auto offsets = ColumnArray::ColumnOffsets::create();
+    offsets->insert_value(1);
+    return offsets;
+}
+
+} // namespace
+
+TEST(ColumnMutateSubcolumnsTest, NullableKeepsExclusiveSubcolumns) {
+    ColumnPtr nullable = ColumnNullable::create(create_int64_column(10), 
create_uint8_column(0));
+    const auto& nullable_ref = assert_cast<const ColumnNullable&>(*nullable);
+    const auto* nested_raw = nullable_ref.get_nested_column_ptr().get();
+    const auto* null_map_raw = nullable_ref.get_null_map_column_ptr().get();
+
+    auto mutated = IColumn::mutate(std::move(nullable));
+    const auto& mutated_nullable = assert_cast<const 
ColumnNullable&>(*mutated);
+
+    EXPECT_EQ(mutated_nullable.get_nested_column_ptr().get(), nested_raw);
+    EXPECT_EQ(mutated_nullable.get_null_map_column_ptr().get(), null_map_raw);
+}
+
+TEST(ColumnMutateSubcolumnsTest, NullableDetachesSharedSubcolumns) {
+    ColumnPtr nested = create_int64_column(10);
+    ColumnPtr nested_alias = nested;
+    ColumnPtr null_map = create_uint8_column(0);
+    ColumnPtr null_map_alias = null_map;
+
+    ColumnPtr nullable = ColumnNullable::create(nested, null_map);
+    auto mutated = IColumn::mutate(std::move(nullable));
+    auto& mutated_nullable = assert_cast<ColumnNullable&>(*mutated);
+
+    EXPECT_NE(mutated_nullable.get_nested_column_ptr().get(), 
nested_alias.get());
+    EXPECT_NE(mutated_nullable.get_null_map_column_ptr().get(), 
null_map_alias.get());
+    EXPECT_EQ(mutated_nullable.get_null_map_data()[0], 0);
+
+    mutated_nullable.get_null_map_data()[0] = 1;
+    const auto& original_null_map = assert_cast<const 
ColumnUInt8&>(*null_map_alias);
+    EXPECT_EQ(original_null_map.get_data()[0], 0);
+}
+
+TEST(ColumnMutateSubcolumnsTest, ArrayKeepsExclusiveSubcolumns) {

Review Comment:
   This only exercises the shared-child COW path for `ColumnNullable`; the 
other wrappers changed in this PR only check the exclusive fast path. For 
example, `ColumnArray::mutate_subcolumns()` now detaches both `offsets` and 
`data`, `ColumnMap` detaches keys/values/offsets, `ColumnConst` detaches 
`data`, and `ColumnStruct` detaches every field. If any of those overrides 
forgot one child or used the wrong typed helper, these tests would still pass 
because lines 82-137 only assert that exclusive children keep the same pointer. 
Please add shared-alias cases for the other changed composite columns and 
mutate the result to prove the original alias remains unchanged, like 
`NullableDetachesSharedSubcolumns` does.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to