Jackie-Jiang commented on a change in pull request #7214: URL: https://github.com/apache/pinot/pull/7214#discussion_r684445246
########## File path: pinot-common/src/main/java/org/apache/pinot/common/request/context/predicate/LikePredicate.java ########## @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.common.request.context.predicate; + +import org.apache.pinot.common.request.context.ExpressionContext; + +/** + * Predicate which represents a LIKE operator + */ +public class LikePredicate extends RegexpLikePredicate { Review comment: Since we are using `regexpLike` to handle the `LIKE`, let's not add another `Predicate`, but add a util to convert the `LIKE` value to `regexpLike` format. Everything else should automatically work without code change ########## File path: pinot-common/src/main/java/org/apache/pinot/common/request/context/predicate/LikePredicate.java ########## @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.common.request.context.predicate; + +import org.apache.pinot.common.request.context.ExpressionContext; + +/** + * Predicate which represents a LIKE operator + */ +public class LikePredicate extends RegexpLikePredicate { + public static final String[] REGEXP_METACHARACTERS = {"\\","^","$","{","}","[","]","(",")",".", + "*","+","?","|","<",">","-","&"}; + + public LikePredicate(ExpressionContext lhs, String value) { + super(lhs, processValue(value)); + } + + @Override + public Type getType() { + return Type.LIKE; + } + + @Override + public String toString() { + return _lhs + "LIKE" + _value; + } + + /** + * Process an incoming LIKE string and make it regexp friendly + * @param value + * @return + */ + private static String processValue(String value) { Review comment: Let's make this a util and add a unit test for it ########## File path: pinot-core/src/test/java/org/apache/pinot/queries/TextSearchQueriesTest.java ########## @@ -1199,6 +1199,26 @@ public void testLuceneRealtimeWithSearcherManager() indexWriter.close(); } + @Test + public void testLikeOperator() Review comment: I don't think we should put the test under this class because `regexpLike` won't leverage text index currently ########## File path: pinot-common/src/main/java/org/apache/pinot/common/request/context/RequestContextUtils.java ########## @@ -229,6 +230,9 @@ public static FilterContext getFilter(Expression thriftExpression) { case REGEXP_LIKE: return new FilterContext(FilterContext.Type.PREDICATE, null, new RegexpLikePredicate(getExpression(operands.get(0)), getStringValue(operands.get(1)))); + case LIKE: + return new FilterContext(FilterContext.Type.PREDICATE, null, + new LikePredicate(getExpression(operands.get(0)), getStringValue(operands.get(1)))); Review comment: Directly create a `RegexpLikePredicate` here with converted value ########## File path: pinot-common/src/main/java/org/apache/pinot/common/request/context/predicate/LikePredicate.java ########## @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.common.request.context.predicate; + +import org.apache.pinot.common.request.context.ExpressionContext; + +/** + * Predicate which represents a LIKE operator + */ +public class LikePredicate extends RegexpLikePredicate { + public static final String[] REGEXP_METACHARACTERS = {"\\","^","$","{","}","[","]","(",")",".", + "*","+","?","|","<",">","-","&"}; + + public LikePredicate(ExpressionContext lhs, String value) { + super(lhs, processValue(value)); + } + + @Override + public Type getType() { + return Type.LIKE; + } + + @Override + public String toString() { + return _lhs + "LIKE" + _value; Review comment: The `_value` format is not compatible with `LIKE` but `regexpLike` here -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org