beliefer opened a new pull request #27432: [SPARK-28325][SQL]Support ANSI SQL: 
SIMILAR TO ... ESCAPE syntax
URL: https://github.com/apache/spark/pull/27432
 
 
   ### What changes were proposed in this pull request?
   `[ NOT ] SIMILAR TO <similar pattern> [ ESCAPE <escape character> ]`
   This is a ANSI SQL.
   For example:
   ```
   SELECT 'abc' SIMILAR TO 'abc' AS `true`;
   SELECT 'abc' SIMILAR TO 'a' AS `false`;
   SELECT 'abc' SIMILAR TO '%(b|d)%' AS `true`;
   SELECT 'abc' SIMILAR TO '(b|c)%' AS `false`;
   ```
   There are some mainstream database support the syntax.
   **PostgreSQL:**
   
https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP
   **Redshift:**
   
https://docs.aws.amazon.com/redshift/latest/dg/pattern-matching-conditions-similar-to.html
   
   `SIMILAR TO` is similar to `RLIKE`, but with the following differences:
          1. The `SIMILAR TO` operator returns true only if its pattern matches 
the entire string,
             unlike `RLIKE` behavior, where the pattern can match any portion 
of the string.
          2. The regex string allow uses _ and % as wildcard characters 
denoting any single character
             and any string, respectively (these are comparable to . and .* in 
POSIX regular
             expressions).
          3. The regex string allow uses escape character like `LIKE` behavior.
          4. '.', '^' and '$' is not a meta character for `SIMILAR TO`.
   
   
   ### Why are the changes needed?
   Support ANSI SQL: `SIMILAR TO ... ESCAPE` syntax
   `SIMILAR TO ... ESCAPE ` has a lot of convenience compared to `RLIKE`.
   
   
   ### Does this PR introduce any user-facing change?
   No
   
   
   ### How was this patch tested?
   Exists and new UT

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to