You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Jungtaek Lim (Jira)" <ji...@apache.org> on 2019/09/28 06:47:00 UTC

[jira] [Created] (SPARK-29281) Examples in Like/RLike doesn't consider the default value of spark.sql.parser.escapedStringLiterals

Jungtaek Lim created SPARK-29281:
------------------------------------

             Summary: Examples in Like/RLike doesn't consider the default value of spark.sql.parser.escapedStringLiterals
                 Key: SPARK-29281
                 URL: https://issues.apache.org/jira/browse/SPARK-29281
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.0.0
            Reporter: Jungtaek Lim


Please take a look at example of `LIKE`:

[https://github.com/apache/spark/blob/d72f39897b00d0bbd7a4db9de281a1256fcf908d/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/regexpExpressions.scala#L97-L106]

If spark.sql.parser.escapedStringLiterals=false, then it should fail as there's `\U` in pattern (spark.sql.parser.escapedStringLiterals=false by default) but it doesn't fail.
{quote}The escape character is '\'. If an escape character precedes a special symbol or another
 escape character, the following character is matched literally. It is invalid to escape
 any other character.
{quote}
For the query
{code:java}
SET spark.sql.parser.escapedStringLiterals=false;
SELECT '%SystemDrive%\Users\John' like '\%SystemDrive\%\Users%'; {code}
SQL parser removes single `\` (not sure that is intended) so the expressions of Like are constructed as following:
{code:java}
 LIKE - left `%SystemDrive%UsersJohn` / right `\%SystemDrive\%Users%`{code}
which are no longer having origin intention. 

Same happens on RLike example:
{code:java}
SET spark.sql.parser.escapedStringLiterals=false;
SELECT '%SystemDrive%\Users\John' rlike '%SystemDrive%\Users.*'; {code}
{code:java}
RLIKE - left `%SystemDrive%UsersJohn` / right `%SystemDrive%Users.*`{code}
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org