Dwrite commented on code in PR #5158:
URL: https://github.com/apache/calcite/pull/5158#discussion_r3740842214
##########
core/src/main/java/org/apache/calcite/runtime/Like.java:
##########
@@ -110,6 +110,71 @@ static String sqlToRegexLike(
return javaPattern.toString();
}
+ /**
+ * Translates a SQL LIKE pattern to a MongoDB regular expression, with an
+ * optional escape string.
+ *
+ * <p>Similar to {@link #sqlToRegexLike}, except that the result is anchored
+ * with {@code ^} and {@code $} so that the entire value must match, as SQL
+ * LIKE requires.
+ */
+ public static String sqlToRegexMongo(
Review Comment:
This method is now public static in core, but its name (sqlToRegexMongo)
makes it look Mongo-specific even though the logic is generic (anchored regex
translation). Worth either noting in the javadoc that it's not actually
Mongo-exclusive, or using a more neutral name — not blocking, just a naming nit.
##########
mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoFilter.java:
##########
@@ -404,8 +405,8 @@ private static RexNode stripCast(RexNode node) {
return node;
}
- /** Returns the escape character declared in a LIKE expression, or null. */
- private static @Nullable Character escapeChar(RexCall call) {
Review Comment:
Should we rename this to escapeStr to match the parameter name in
Like.sqlToRegexMongo? (escapeString also works but reads a bit ambiguous —
could be misread as "a string that's been escaped" rather than "the escape
string from the LIKE clause".)
--
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]