gary-cloud commented on code in PR #60362:
URL: https://github.com/apache/doris/pull/60362#discussion_r2757721394


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -316,6 +360,9 @@ public Expression visitUnboundSlot(UnboundSlot unboundSlot, 
ExpressionRewriteCon
                 } else if (firstBound.containsType(ElementAt.class, 
StructElement.class)) {
                     
context.cascadesContext.getStatementContext().setHasNestedColumns(true);
                 }
+                if (firstBound instanceof Alias) {

Review Comment:
   > why change this
   
   to support path-style grammar such as `data.int_nested.level1_num_1`, such 
paths are wrapped in an Alias expression.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -869,7 +1012,17 @@ public Expression visitMatch(Match match, 
ExpressionRewriteContext context) {
 
     @Override
     public Expression visitCast(Cast cast, ExpressionRewriteContext context) {
-        cast = (Cast) super.visitCast(cast, context);
+        boolean suppressVariantElementAtCast = 
shouldSuppressVariantElementAtCast(cast);
+        if (suppressVariantElementAtCast) {

Review Comment:
   will fix it



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/VariantField.java:
##########
@@ -67,6 +67,138 @@ public String getComment() {
         return comment;
     }
 
+    public TPatternType getPatternType() {
+        return patternType;
+    }
+
+    /**
+     * Check if the given field name matches this field's pattern.
+     * This method aligns with BE's fnmatch(pattern, path, FNM_PATHNAME) 
behavior.
+     *
+     * Supported glob syntax:
+     * - '*' matches any sequence of characters except '/'
+     * - '?' matches any single character except '/'
+     * - '[...]' matches any character in the brackets
+     * - '[!...]' or '[^...]' matches any character not in the brackets
+     *
+     * @param fieldName the field name to check
+     * @return true if the field name matches the pattern
+     */
+    public boolean matches(String fieldName) {
+        if (patternType == TPatternType.MATCH_NAME) {
+            return pattern.equals(fieldName);
+        } else {
+            // MATCH_NAME_GLOB: convert glob pattern to regex
+            // This aligns with BE's fnmatch(pattern, path, FNM_PATHNAME)
+            String regex = globToRegex(pattern);
+            return fieldName.matches(regex);
+        }
+    }
+
+    /**
+     * Convert glob pattern to regex pattern, aligning with 
fnmatch(FNM_PATHNAME) behavior.
+     *
+     * fnmatch with FNM_PATHNAME flag behavior:
+     * - '*' matches any sequence of characters except '/'
+     * - '?' matches any single character except '/'
+     * - '[...]' matches any character in the brackets
+     * - '[!...]' or '[^...]' matches any character not in the brackets
+     * - '\' escapes the next character (e.g., '\*' matches literal '*')
+     */
+    private static String globToRegex(String glob) {

Review Comment:
   will fix it



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