[ 
https://issues.apache.org/jira/browse/CALCITE-7673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18101843#comment-18101843
 ] 

Julian Hyde commented on CALCITE-7673:
--------------------------------------

We've used this approach before. See, for example, 
[Like.sqlToRegexLike|https://github.com/apache/calcite/blob/fc95bb0e68c838da4232aabf47ee5037cf73b778/core/src/main/java/org/apache/calcite/runtime/Like.java#L60].
 If you move your {{sqlLikeToMongoRegex}} function to {{SqlLike.java}} I think 
you could make it more uniform.

Your code would benefit from some one-line unit tests, e.g. 
{{{}assertThat(sqlLikeToMongoRegex(""), is("")){}}}.

> Add support for the LIKE operator to the MongoDB adapter
> --------------------------------------------------------
>
>                 Key: CALCITE-7673
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7673
>             Project: Calcite
>          Issue Type: Improvement
>          Components: mongodb-adapter
>    Affects Versions: 1.42.0
>            Reporter: Yu Xu
>            Assignee: Yu Xu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.43.0
>
>
> Currently MongoDB Adapter not support LIKE operator.
> sql:
> {code:java}
> select state, city from zips where state like 'A%' order by state;{code}
> would error out:
> {code:java}
> java.lang.AssertionError: cannot translate LIKE(CAST(ITEM($0, 
> 'city')):VARCHAR(20), 'A%')  {code}
> However, MongoDB can achieve SQL-like `LIKE` semantics using `$regex`. we can 
> refer:[https://www.mongodb.com/docs/manual/reference/operator/query/regex/#mongodb-query-op.-regex]
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to