mihaibudiu commented on code in PR #4434:
URL: https://github.com/apache/calcite/pull/4434#discussion_r2164658621


##########
elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/QueryBuilders.java:
##########
@@ -497,14 +510,80 @@ static class RegexpQueryBuilder extends QueryBuilder {
     private final String fieldName;
     @SuppressWarnings("unused")
     private final String value;
+    @SuppressWarnings("unused")
+    private String escape;
 
     RegexpQueryBuilder(final String fieldName, final String value) {
+      this(fieldName, value, "\\");
+    }
+
+    RegexpQueryBuilder(final String fieldName, final String value, final 
String escape) {
+      requireNonNull(fieldName, "fieldName");
+      requireNonNull(value, "value");
+      requireNonNull(escape, "escape");
       this.fieldName = fieldName;
-      this.value = value;
+      this.escape = escape;
+      // replace % to * and _ to ? for sql with like operator
+      HashMap<String, String> kv = new HashMap<>();
+      kv.put("%", "*");
+      kv.put("_", "?");
+      this.value = replaceWildcard(value, kv, escape);
+    }
+
+    public static String replaceWildcard(String value, Map<String, String> kv, 
String escape) {

Review Comment:
   SqlFunctions has an implementation of like, I wonder whether anything there 
can be reused.



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