fhueske commented on code in PR #28292:
URL: https://github.com/apache/flink/pull/28292#discussion_r3340273562
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java:
##########
@@ -1015,14 +1015,19 @@ public static Integer hashCode(String str) {
return Math.abs(str.hashCode());
}
+ /**
+ * Returns whether {@code s} contains a match for the regular expression
{@code regex}. Literal
+ * regexes are validated at planning time by the input type strategy.
+ */
public static Boolean regExp(String s, String regex) {
if (regex.length() == 0) {
return false;
}
try {
- return (REGEXP_PATTERN_CACHE.get(regex)).matcher(s).find(0);
- } catch (Exception e) {
- LOG.error("Exception when compile and match regex:" + regex + "
on: " + s, e);
+ return REGEXP_PATTERN_CACHE.get(regex).matcher(s).find(0);
+ } catch (PatternSyntaxException e) {
+ // Literals are rejected at planning time; non-literal invalid
regex
+ // returns false to preserve the prior runtime contract.
return false;
Review Comment:
AFAIK, most engines terminate a statement if they encounter an invalid regex
pattern.
However, since the fix "just" removes the logging we are not changing the
current behavior.
So this change is OK, IMO.
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java:
##########
@@ -1015,14 +1015,19 @@ public static Integer hashCode(String str) {
return Math.abs(str.hashCode());
}
+ /**
+ * Returns whether {@code s} contains a match for the regular expression
{@code regex}. Literal
+ * regexes are validated at planning time by the input type strategy.
+ */
public static Boolean regExp(String s, String regex) {
if (regex.length() == 0) {
Review Comment:
The method call is wrapped in `GenerateUtils.generateCallIfArgsNotNull()`.
So the input args should not be null.
--
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]