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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NestedColumnPruning.java:
##########
@@ -323,6 +344,41 @@ private static Map<Integer, AccessPathInfo> pruneDataType(
         return result;
     }
 
+    /**
+     * Compares two path-prefix lists for semantic equality, treating the map 
element-access
+     * token {@code *} (ACCESS_ALL) as equivalent to {@code VALUES} 
(ACCESS_MAP_VALUES).
+     *
+     * <p>{@code element_at(map_col, key)} collects path {@code [map_col, *]} 
while
+     * {@code map_values(map_col)} collects path {@code [map_col, VALUES]}. 
Both target
+     * the same value container, so an OFFSET path through {@code *} should be 
suppressed
+     * when a non-OFFSET path through {@code VALUES} already covers the values 
(and vice versa).
+     */
+    private static boolean prefixSemanticEquals(List<String> a, List<String> 
b) {
+        if (a.size() != b.size()) {
+            return false;
+        }
+        for (int i = 0; i < a.size(); i++) {
+            if (!pathComponentSemanticEquals(a.get(i), b.get(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private static boolean pathComponentSemanticEquals(String a, String b) {
+        if (a.equals(b)) {
+            return true;
+        }
+        // * (element-at) accesses map values via key lookup; VALUES accesses 
map values directly.
+        // Both cover the same value container, so treat them as equivalent 
for OFFSET suppression.
+        // Do NOT treat * as equivalent to KEYS. For example:
+        //   select length(map_col['a']), map_keys(map_col) from t
+        // map_keys(map_col) only covers the key side, while 
length(map_col['a']) still needs

Review Comment:
   This comparison is not safe in both directions. A `[map_col, *]` path means 
`element_at(map, key)` style access, and the BE uses it to keep the map key 
iterator readable as well as the value iterator (see 
`MapFileColumnIterator::set_access_paths()`). `[map_col, VALUES]` only 
preserves the value side. With this change, `select length(map_col['a']), 
map_values(map_col)[1] ...` drops `[map_col, *, OFFSET]` and keeps only 
`[map_col, VALUES]`; BE then sets the key iterator to `SKIP_READING`, so the 
`element_at(map_col, 'a')` inside `length()` can no longer match the key and 
returns NULL/defaults. The `*` vs `VALUES` relation here needs to be 
directional, or this case needs to be rewritten to `KEYS + VALUES` rather than 
removing the `*` path entirely.



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