tanclary commented on code in PR #3338:
URL: https://github.com/apache/calcite/pull/3338#discussion_r1295388897


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -345,6 +346,17 @@ public static String sha512(ByteString string)  {
     return DigestUtils.sha512Hex(string.getBytes());
   }
 
+  /** SQL {@code REGEXP_CONTAINS(value, regexp)} function.
+   * Throws a runtime exception for invalid regular expressions.*/
+  public static boolean regexpContains(String value, String regex) {
+    try {
+      Pattern regexp = Pattern.compile(regex);

Review Comment:
   I think it makes sense to have one in both places because If someone were to 
write a query using regex that was valid in the re2 library and not Java, if it 
used Calcite's implementation then the error would get thrown from 
`regexpContains` and the user/developer would be able to reference that comment 
for clarification on the library decision. This comes to mind given the recent 
bugs with split and other functions regarding differing behavior between 
Calcite & BigQuery.



##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -345,6 +346,17 @@ public static String sha512(ByteString string)  {
     return DigestUtils.sha512Hex(string.getBytes());
   }
 
+  /** SQL {@code REGEXP_CONTAINS(value, regexp)} function.
+   * Throws a runtime exception for invalid regular expressions.*/
+  public static boolean regexpContains(String value, String regex) {
+    try {
+      Pattern regexp = Pattern.compile(regex);

Review Comment:
   I think it makes sense to have one in both places because If someone were to 
write a query using regex that was valid in the re2 library and not Java, if it 
used Calcite's implementation then the error would get thrown from 
`regexpContains` and the user/developer would be able to reference that comment 
for clarification on the library decision. This comes to mind given the recent 
bugs with `split` and other functions regarding differing behavior between 
Calcite & BigQuery.



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