Copilot commented on code in PR #63104:
URL: https://github.com/apache/doris/pull/63104#discussion_r3212908761


##########
be/test/exec/common/schema_util_test.cpp:
##########
@@ -1224,20 +1225,16 @@ TEST_F(SchemaUtilTest, 
get_extended_compaction_schema_nested_group_preserves_typ
             rowsets, target_schema);
     ASSERT_TRUE(status.ok()) << status.to_string();
 
-    EXPECT_EQ(target_schema->num_columns(), 2);
+    // get_extended_compaction_schema rebuilds from the base columns. Real 
compaction targets do
+    // not carry pre-existing extracted columns, so NG compaction must rely on 
rowset metadata for
+    // regular paths and on get_compaction_typed_columns() for typed paths.
+    EXPECT_EQ(target_schema->num_columns(), 1);
     const PathInData typed_path("v1.owner", true);
-    const auto typed_column_index = target_schema->field_index(typed_path);
-    ASSERT_NE(typed_column_index, -1);
-
-    const auto& preserved_typed_column = 
target_schema->column(typed_column_index);
-    EXPECT_TRUE(preserved_typed_column.path_info_ptr()->get_is_typed());
-    EXPECT_EQ(preserved_typed_column.type(), 
FieldType::OLAP_FIELD_TYPE_STRING);
+    EXPECT_EQ(target_schema->field_index(typed_path), -1);
 
     const auto* path_set_info = target_schema->try_path_set_info(1);
     ASSERT_NE(path_set_info, nullptr);
-    ASSERT_TRUE(path_set_info->typed_path_set.contains("owner"));
-    EXPECT_EQ(path_set_info->typed_path_set.at("owner").indexes.size(), 1);
-    
EXPECT_EQ(path_set_info->typed_path_set.at("owner").indexes[0]->index_name(), 
"v1_owner_idx");
+    EXPECT_FALSE(path_set_info->typed_path_set.contains("owner"));

Review Comment:
   The updated NestedGroup compaction logic now materializes regular (non-NG) 
paths via `collect_regular_types_outside_nested_group()` + 
`get_compaction_subcolumns_from_data_types()`, but there is no unit test 
covering the positive case (i.e., rowset metadata contains both NG paths and a 
sibling regular path like `owner`, and the resulting compaction schema 
materializes `v1.owner` and records it in `path_set_info.sub_path_set`). The 
current test only asserts that pre-existing extracted columns in the target 
schema are ignored. Adding a regression test for the new contract would help 
prevent future breakage.



##########
be/src/exec/common/variant_util.cpp:
##########
@@ -1374,27 +1293,37 @@ Status 
VariantCompactionUtil::get_extended_compaction_schema(
                                                            ? 
empty_extended_info
                                                            : info_it->second;
         auto& paths_set_info = uid_to_paths_set_info[column->unique_id()];
-        if (ng_root_uids.contains(column->unique_id())) {
-            const auto plan = 
build_nested_group_compaction_materialization_plan(
-                    uid_to_existing_ng_subcolumns.contains(column->unique_id())
-                            ? 
uid_to_existing_ng_subcolumns.at(column->unique_id())
-                            : std::vector<TabletColumnPtr> {},
-                    extended_info);
-            append_nested_group_compaction_columns(target, column, plan, 
output_schema,
-                                                   paths_set_info);
-            LOG(INFO) << "Variant column uid=" << column->unique_id()
-                      << " keeps nested-group root with regular extracted 
columns in compaction "
-                         "schema";
-            continue;
-        }
-        if (!should_check_variant_path_stats(*column)) {
-            VLOG_DEBUG << "skip extended schema compaction for variant uid=" 
<< column->unique_id()
-                       << " because the column disables variant path stats";
-            continue;
+        const bool use_nested_group_compaction_schema = 
ng_root_uids.contains(column->unique_id());
+        if (!use_nested_group_compaction_schema) {
+            if (!should_check_variant_path_stats(*column)) {
+                VLOG_DEBUG << "skip extended schema compaction for variant 
uid="
+                           << column->unique_id()
+                           << " because the column disables variant path 
stats";
+                continue;
+            }
+            if (extended_info.has_nested_group) {
+                LOG(INFO) << "Variant column uid=" << column->unique_id()
+                          << " has nested group, keep original column in 
compaction schema";
+                continue;
+            }

Review Comment:
   The `extended_info.has_nested_group` check inside the 
`!use_nested_group_compaction_schema` branch appears to be unreachable: 
`use_nested_group_compaction_schema` is computed from `ng_root_uids`, and 
`ng_root_uids` is built using the same `has_nested_group` predicate. Keeping 
this branch makes control flow harder to follow and suggests a state that 
cannot occur; consider removing it (or adjust `ng_root_uids` computation if 
there really are cases where `has_nested_group` should not imply NG schema).
   



-- 
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