[feature](Nereids) add keyword rlike (#15647)

This commit is contained in:
mch_ucchi
2023-01-07 00:28:21 +08:00
committed by GitHub
parent a6773417ef
commit 08d439cde7
4 changed files with 44 additions and 1 deletions

View File

@ -249,7 +249,7 @@ booleanExpression
predicate
: NOT? kind=BETWEEN lower=valueExpression AND upper=valueExpression
| NOT? kind=(LIKE | REGEXP) pattern=valueExpression
| NOT? kind=(LIKE | REGEXP | RLIKE) pattern=valueExpression
| NOT? kind=IN LEFT_PAREN expression (COMMA expression)* RIGHT_PAREN
| NOT? kind=IN LEFT_PAREN query RIGHT_PAREN
| IS NOT? kind=NULL

View File

@ -1418,6 +1418,7 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
getExpression(ctx.pattern)
);
break;
case DorisParser.RLIKE:
case DorisParser.REGEXP:
outExpression = new Regexp(
valueExpression,

View File

@ -0,0 +1,15 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !regexp --
Customer#000001309
-- !rlike --
Customer#000001309
-- !not_regexp --
Customer#000001303
Customer#000001312
-- !not_rlike --
Customer#000001303
Customer#000001312

View File

@ -0,0 +1,27 @@
// 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.
suite("rlike") {
sql "use regression_test_nereids_syntax_p0"
sql "set enable_nereids_planner=true"
sql "set enable_fallback_to_original_planner=false"
qt_regexp "select c_name from customer where c_name regexp '9' order by c_custkey"
qt_rlike "select c_name from customer where c_name rlike '9' order by c_custkey"
qt_not_regexp "select c_name from customer where c_name not regexp '9' order by c_custkey"
qt_not_rlike "select c_name from customer where c_name not rlike '9' order by c_custkey"
}