lincoln-lil commented on code in PR #25137:
URL: https://github.com/apache/flink/pull/25137#discussion_r1722900737
##########
docs/data/sql_functions.yml:
##########
@@ -323,16 +323,14 @@ string:
- sql: REPLACE(string1, string2, string3)
table: STRING1.replace(STRING2, STRING3)
description: Returns a new string which replaces all the occurrences of
STRING2 with STRING3 (non-overlapping) from STRING1. E.g., 'hello
world'.replace('world', 'flink') returns 'hello flink';
'ababab'.replace('abab', 'z') returns 'zab'.
- - sql: TRANSLATE(expr, fromStr, toStr)
- table: expr.translate(fromStr, toStr)
+ - sql: REGEXP_COUNT(str, regex)
+ table: str.regexpCount(regex)
description: |
- Translate an expr where all characters in fromStr have been replaced
with those in toStr.
+ Returns the number of times str matches the regex pattern. regex must be
a Java regular expression.
- If toStr has a shorter length than fromStr, unmatched characters are
removed.
+ str <CHAR | VARCHAR>, regex <CHAR | VARCHAR>
- expr <CHAR | VARCHAR>, fromStr <CHAR | VARCHAR>, toStr <CHAR | VARCHAR>
-
- Returns a STRING of translated expr.
+ Returns an INTEGER representation of matching times. `NULL` if any of
the arguments are `NULL` or regex is invalid.
Review Comment:
-> 'Returns an INTEGER representation of the number of matches.' ?
##########
flink-python/pyflink/table/expression.py:
##########
@@ -1204,6 +1204,17 @@ def regexp(self, regex: Union[str, 'Expression[str]'])
-> 'Expression[str]':
"""
return _binary_op("regexp")(self, regex)
+ def regexp_count(self, regex) -> 'Expression':
+ """
+ Returns the number of times str matches the regex pattern.
+ regex must be a Java regular expression.
+ null if any of the arguments are null or regex is invalid.
+
+ :param regex: A STRING expression with a matching pattern.
+ :return: An INTEGER representation of matching times.
Review Comment:
ditto
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/BaseExpressions.java:
##########
@@ -1136,6 +1137,19 @@ public OutType regexp(InType regex) {
return toApiSpecificExpression(unresolvedCall(REGEXP, toExpr(),
objectToExpression(regex)));
}
+ /**
+ * Returns the number of times {@code str} matches the {@code regex}
pattern. {@code regex} must
+ * be a Java regular expression.
+ *
+ * @param regex A STRING expression with a matching pattern.
+ * @return An INTEGER representation of matching times. <br>
Review Comment:
ditto
--
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]