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


##########
be/src/format/parquet/parquet_nested_column_utils.cpp:
##########
@@ -0,0 +1,555 @@
+// 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 "format/parquet/parquet_nested_column_utils.h"
+
+#include <algorithm>
+#include <cctype>
+#include <string_view>
+#include <unordered_map>
+#include <utility>
+
+#include "core/data_type/data_type_nullable.h"
+#include "format/parquet/schema_desc.h"
+
+namespace doris {
+namespace {
+
+enum class NestedPathMode {
+    NAME,
+    FIELD_ID,
+};
+
+void add_column_id_range(const FieldSchema& field_schema, std::set<uint64_t>& 
column_ids) {
+    const uint64_t start_id = field_schema.get_column_id();
+    const uint64_t max_column_id = field_schema.get_max_column_id();
+    for (uint64_t id = start_id; id <= max_column_id; ++id) {
+        column_ids.insert(id);
+    }
+}
+
+const FieldSchema* find_child_by_structural_name(const FieldSchema& 
field_schema,
+                                                 std::string_view name) {
+    std::string lower_name(name);
+    std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(),
+                   [](unsigned char c) { return 
static_cast<char>(std::tolower(c)); });
+    for (const auto& child : field_schema.children) {
+        if (child.name == name || child.lower_case_name == lower_name) {
+            return &child;
+        }
+    }
+    return nullptr;
+}
+
+const FieldSchema* find_child_by_exact_name(const FieldSchema& field_schema,
+                                            std::string_view name) {
+    for (const auto& child : field_schema.children) {
+        if (child.name == name) {
+            return &child;
+        }
+    }
+    return nullptr;
+}
+
+const FieldSchema* find_variant_typed_child_by_key(const FieldSchema& 
field_schema,
+                                                   std::string_view key, 
NestedPathMode mode) {
+    if (const auto* child = find_child_by_exact_name(field_schema, key)) {
+        return child;
+    }
+    if (mode == NestedPathMode::NAME) {
+        return nullptr;
+    }
+    for (const auto& child : field_schema.children) {

Review Comment:
   In the Iceberg path this helper runs in `FIELD_ID` mode, but VARIANT 
subpaths are still logical VARIANT object keys, not Iceberg field IDs: 
`SlotTypeReplacer` leaves `VariantType` path components unchanged after 
converting only the top-level Iceberg column id. With this fallback, a query 
for a numeric key that is absent, for example `v['20']`, can match a different 
shredded typed child whose Parquet/Iceberg field id is `20` and select that 
column instead of falling back to the residual/missing-key behavior. That can 
return the wrong sibling or suppress the residual `value` path. This is 
distinct from the existing map-key field-id serialization thread because it is 
the BE VARIANT typed-child lookup interpreting user keys as field ids. Please 
keep VARIANT keys name-based in field-id mode (or only use field-id matching 
for paths that FE actually serialized as field ids) and add coverage for 
numeric-looking VARIANT keys colliding with another typed child's field id.



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