raminqaf commented on code in PR #28140:
URL: https://github.com/apache/flink/pull/28140#discussion_r3218685289
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java:
##########
@@ -444,26 +443,19 @@ public static String regexpReplace(String str, String
regex, String replacement)
/**
* Returns a string extracted with a specified regular expression and a
regex match group index.
+ * Literal regexes are validated at planning time by the input type
strategy.
*/
public static String regexpExtract(String str, String regex, int
extractIndex) {
- if (str == null || regex == null) {
+ if (str == null || regex == null || extractIndex < 0) {
return null;
}
-
- try {
- Matcher m = Pattern.compile(regex).matcher(str);
- if (m.find()) {
- MatchResult mr = m.toMatchResult();
- return mr.group(extractIndex);
- }
- } catch (Exception e) {
- LOG.error(
- String.format(
- "Exception in regexpExtract('%s', '%s', '%d')",
- str, regex, extractIndex),
- e);
+ final Matcher m = REGEXP_PATTERN_CACHE.get(regex).matcher(str);
Review Comment:
Good catch here @dylanhz! I have addressed your feedback and added a IT to
cover this case
--
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]