eldenmoon commented on code in PR #66310:
URL: https://github.com/apache/doris/pull/66310#discussion_r3686199249


##########
be/src/format_v2/column_mapper.cpp:
##########
@@ -58,6 +60,67 @@ namespace doris::format {
 
 namespace {
 
+std::string mapping_mode_to_string(TableColumnMappingMode mode);
+
+bool is_variant_v2_type(const DataTypePtr& type) {
+    return type != nullptr &&
+           dynamic_cast<const DataTypeVariantV2*>(remove_nullable(type).get()) 
!= nullptr;
+}
+
+Status resolve_variant_path(const std::vector<std::string>& column_paths,
+                            std::shared_ptr<const 
ResolvedVariantElementV2Path>* resolved_path) {
+    DORIS_CHECK(!column_paths.empty());
+    DORIS_CHECK(resolved_path != nullptr);
+    std::vector<VariantElementV2PathSegment> segments;
+    segments.reserve(column_paths.size());
+    for (const auto& key : column_paths) {
+        // TSlotDescriptor.column_paths is an already-tokenized list. Treat 
every entry as one
+        // object key; joining on '.' would turn a literal key such as "a.b" 
into two selectors.
+        // Array indexes need a typed transport and are intentionally outside 
this contract.
+        segments.push_back(
+                VariantElementV2PathSegment::object_key(StringRef(key.data(), 
key.size())));
+    }
+    std::unique_ptr<ResolvedVariantElementV2Path> candidate;
+    RETURN_IF_ERROR(resolve_variant_element_v2_path(segments, &candidate));
+    *resolved_path = std::move(candidate);
+    return Status::OK();
+}
+
+Status initialize_variant_path_mapping(const ColumnDefinition& table_column,
+                                       TableColumnMappingMode mode, 
ColumnMapping* mapping) {
+    DORIS_CHECK(mapping != nullptr);
+    mapping->column_paths = table_column.column_paths;
+    if (mapping->column_paths.empty()) {
+        return Status::OK();
+    }
+    if (mode != TableColumnMappingMode::BY_FIELD_ID) {

Review Comment:
   Fixed in 171f33ed2a46. Path Slots now retain the root name/alias identity 
for BY_NAME legacy files, while the Iceberg field id remains authoritative when 
history exists. A missing historical id records an authoritative empty alias 
set, so it cannot bind to a later same-name/different-id field; an entirely 
idless file still maps by the retained root alias, and a missing idless root 
reaches the existing default/SQL-NULL path. Covered by 
VariantPathSlotsSupportIdlessNameMappingAndRejectPositionMapping, 
VariantPathSlotsKeepAuthoritativeNameAndFieldIdSafety, 
IcebergMappingModeUsesNameForEntirelyIdlessFile, 
AnnotateVariantPathSlotDoesNotFallbackAfterMissingFieldId, 
AnnotateVariantPathSlotKeepsAuthoritativeEmptyNameMapping, and 
MissingVariantPathRootExtractsFromDefaultCarrier.



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