Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class StringRegexExpression extends BinaryExpression
override def sql: String = s"${left.sql} ${prettyName.toUpperCase(Locale.ROOT)} ${right.sql}"
}


// scalastyle:off line.contains.tab
/**
* Simple RegEx pattern matching function
*/
Expand Down Expand Up @@ -96,13 +96,20 @@ abstract class StringRegexExpression extends BinaryExpression
""",
examples = """
Examples:
> SELECT '%SystemDrive%\Users\John' _FUNC_ '\%SystemDrive\%\Users%';
> SET spark.sql.parser.escapedStringLiterals=true;
spark.sql.parser.escapedStringLiterals true
> SELECT '%SystemDrive%\Users\John' _FUNC_ '\%SystemDrive\%\\Users%';
true
> SET spark.sql.parser.escapedStringLiterals=false;
spark.sql.parser.escapedStringLiterals false
> SELECT '%SystemDrive%\\Users\\John' _FUNC_ '\%SystemDrive\%\\\\Users%';
true
""",
note = """
Use RLIKE to match with standard regular expressions.
""",
since = "1.0.0")
// scalastyle:on line.contains.tab
case class Like(left: Expression, right: Expression) extends StringRegexExpression {

override def escape(v: String): String = StringUtils.escapeLikeRegex(v)
Expand Down Expand Up @@ -177,7 +184,7 @@ case class Like(left: Expression, right: Expression) extends StringRegexExpressi
true
> SET spark.sql.parser.escapedStringLiterals=false;
spark.sql.parser.escapedStringLiterals false
> SELECT '%SystemDrive%\Users\John' _FUNC_ '%SystemDrive%\Users.*';
> SELECT '%SystemDrive%\\Users\\John' _FUNC_ '%SystemDrive%\\\\Users.*';
true
""",
note = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession {
// Examples demonstrate alternative names, see SPARK-20749
"org.apache.spark.sql.catalyst.expressions.Length",
// Uses settings without _FUNC_ in `SET spark.sql.parser.escapedStringLiterals=true`
"org.apache.spark.sql.catalyst.expressions.Like",
"org.apache.spark.sql.catalyst.expressions.RLike")
spark.sessionState.functionRegistry.listFunction().foreach { funcId =>
val info = spark.sessionState.catalog.lookupFunctionInfo(funcId)
Expand Down