OpenMLDB icon indicating copy to clipboard operation
OpenMLDB copied to clipboard

SQL: support the SQL `RLIKE` expression

Open aceforeverd opened this issue 2 years ago • 1 comments

#841 's further work

Brief Description

regex expression match predicate. SQL syntax should be:

<string expr> [ NOT ] RLIKE <pattern> 

Implementation strategy

Generally the implementation steps is the same as the like predicate in #841.

  1. Add grammar support in zetasql, the RLIKE keyword
  2. Logic plan: Treat RLIKE as a binary expr and handle it in hybridse/src/planv2
  3. Physical plan: handle RLIKE ExprNode
  4. Codege: support handle RLIKE expr type in hybridse/src/codegen/expr_ir_builder.{h,cc}
    • require add the builtin udf function REGEXP_LIKE

Well tested

  • each step above should have UT covered
  • end-to-end test yaml test case should added to cases/, testing RLIKE as well as REGEXP_LIKE()

REGEXP_LIKE function

  • should be compatible with the function in MySQL/SparkSQL
  • two version, difference by params
    1. REGEXP_LIKE( <subject> , <pattern>)
    2. REGEXP_LIKE( <subject> , <pattern> [ , <parameters> ] )

have a look of external links:

  • https://docs.snowflake.com/en/sql-reference/functions/rlike.html
  • https://docs.snowflake.com/en/sql-reference/functions/regexp_like.html
  • https://dev.mysql.com/doc/refman/8.0/en/regexp.html#function_regexp-like
  • https://spark.apache.org/docs/latest/api/sql/index.html#regexp_like

Consider

  • the regular expression standard going to adopted and pretty document & example for that
    • it may not so complicated in the first version

Alternative Context

  • it do not support SIMILAR TO predicate defined in ANSI SQL

aceforeverd avatar Dec 08 '21 04:12 aceforeverd

Hi, I'd like to take on this task and plan to complete it within a month.

jiang1997 avatar Jul 17 '22 17:07 jiang1997