You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "caicancai (via GitHub)" <gi...@apache.org> on 2024/03/03 02:52:08 UTC

Re: [PR] [CALCITE-6278] Add REGEXP、REGEXP_LIKE function (enabled in Spark library) [calcite]

caicancai commented on code in PR #3712:
URL: https://github.com/apache/calcite/pull/3712#discussion_r1510154349


##########
babel/src/test/resources/sql/spark.iq:
##########
@@ -0,0 +1,243 @@
+# spark.iq - Babel test for Spark dialect of SQL

Review Comment:
   Are you sure this test only takes effect for semantics that conform to spark sql?



##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -691,7 +691,9 @@ private static int makeRegexpFlags(String stringFlags) {
 
     /** SQL {@code RLIKE} function. */
     public boolean rlike(String s, String pattern) {
-      return cache.getUnchecked(new Key(0, pattern)).matcher(s).find();
+      s = StringEscapeUtils.unescapeJava(s);

Review Comment:
   Do we need to add a little comment?



##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -4928,6 +4928,37 @@ private static void checkIf(SqlOperatorFixture f) {
     f.checkNull("regexp_contains(cast(null as varchar), cast(null as varchar))");
   }
 
+  @Test void testRegexpFunc() {
+    final SqlOperatorFixture f = fixture().setFor(SqlLibraryOperators.REGEXP);

Review Comment:
   fixture().setFor(SqlLibraryOperators.REGEXP).withLibrary(SqlLibrary.Spark) ?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org