raminqaf commented on code in PR #28292:
URL: https://github.com/apache/flink/pull/28292#discussion_r3340412711
##########
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:
This is indeed strange and also raised by @twalthr on my `REGEXP_EXTRACT`:
https://github.com/apache/flink/pull/28140#discussion_r3224575033
We can maybe follow this up and do the changes at once, which would be a
breaking change but IMO a more correct 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]