YiwenWu commented on code in PR #3730:
URL: https://github.com/apache/calcite/pull/3730#discussion_r1524116332


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -680,8 +687,15 @@ private static int makeRegexpFlags(String stringFlags) {
           flags |= Pattern.DOTALL;
           break;
         case 'm':
+          // PostgreSQL should actually interpret m to be a synonym for n, but 
this is
+          // relaxed for consistency.
           flags |= Pattern.MULTILINE;
           break;
+        case 's':

Review Comment:
   There are more optional parameters for Postgres, need to consider them all?
   
   
https://www.postgresql.org/docs/current/functions-matching.html#POSIX-EMBEDDED-OPTIONS-TABLE
   
   



##########
site/_docs/reference.md:
##########
@@ -2820,7 +2820,7 @@ In the following:
 | b | REGEXP_EXTRACT(string, regexp [, position [, occurrence]]) | Returns the 
substring in *string* that matches the *regexp*, starting search at *position* 
(default 1), and until locating the nth *occurrence* (default 1). Returns NULL 
if there is no match
 | b | REGEXP_EXTRACT_ALL(string, regexp)             | Returns an array of all 
substrings in *string* that matches the *regexp*. Returns an empty array if 
there is no match
 | b | REGEXP_INSTR(string, regexp [, position [, occurrence [, 
occurrence_position]]]) | Returns the lowest 1-based position of the substring 
in *string* that matches the *regexp*, starting search at *position* (default 
1), and until locating the nth *occurrence* (default 1). Setting 
occurrence_position (default 0) to 1 returns the end position of substring + 1. 
Returns 0 if there is no match
-| s | REGEXP_LIKE(string, regexp)                    | Equivalent to `string1 
RLIKE string2`
+| m o p s | REGEXP_LIKE(string, regexp [, flags])        | Equivalent to 
`string1 RLIKE string2` with an optional parameter for search flags. Supported 
flags are: <ul><li>i: case-insensitive matching</li><li>c: case-sensitive 
matching</li><li>n: newline-sensitive matching</li><li>s: non-newline-sensitive 
matching</li><li>m: multi-line</li></ul>

Review Comment:
   According to the official website documentation, Oracle and PG `REGEXP_LIKE` 
is equivalent to `LIKE`, and for Spark and MySQL `REGEXP_LIKE` is equivalent to 
`RLIKE`. 
   So they shouldn't be explained together.
   
   



##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -400,11 +400,11 @@ Pattern toPattern() {
 
     /** Validate regex arguments in REGEXP_* fns, throws an exception
      * for invalid regex patterns, else returns a Pattern object. */
-    private Pattern validateRegexPattern(String regex, String methodName) {
+    private Pattern validateRegexPattern(String regex, String methodName, int 
flags) {

Review Comment:
   can be processed using overload. In this way, the upper-level caller does 
not need to change.
   ```
   private Pattern validateRegexPattern(String regex, String methodName) {
        return validateRegexPattern(regex,  methodName, 0);
   }
   ```
   



##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -557,10 +557,10 @@ static RelDataType deriveTypeSplit(SqlOperatorBinding 
operatorBinding,
           SqlFunctionCategory.STRING);
 
   /** The "REGEXP_LIKE(value, regexp)" function, equivalent to {@link #RLIKE}. 
*/
-  @LibraryOperator(libraries = {SPARK})
+  @LibraryOperator(libraries = {SPARK, MYSQL, POSTGRESQL, ORACLE})

Review Comment:
   Spark behaves differently than the other three engines. The regex flags 
parameter is not supported.



-- 
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]

Reply via email to