You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "lvyanquan (via GitHub)" <gi...@apache.org> on 2026/08/04 09:57:32 UTC

Re: [PR] [FLINK-40239][runtime] Support additional Flink SQL regular expression functions in YAML Transform [flink-cdc]

lvyanquan commented on code in PR #4491:
URL: https://github.com/apache/flink-cdc/pull/4491#discussion_r3711078614


##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/functions/impl/StringFunctions.java:
##########
@@ -62,6 +65,72 @@ public static String regexpReplace(String str, String regex, String replacement)
         }
     }
 
+    /** Returns a string extracted with a specified regular expression and capture group index. */
+    public static String regexpExtract(String str, String regex) {
+        return regexpExtract(str, regex, 0);
+    }
+
+    public static String regexpExtract(String str, String regex, Number extractIndex) {
+        if (extractIndex == null || extractIndex.longValue() < 0) {
+            return null;
+        }
+        Matcher matcher = getRegexpMatcher(str, regex);

Review Comment:
   `getRegexpMatcher()` calls `Pattern.compile(regex)` for every record. Since regexes in YAML transforms are usually constant, this adds unnecessary CPU overhead to the per-record hot path. Please use a bounded `ThreadLocalCache<String, Pattern>` while preserving the current invalid-regex behavior.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org