-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-33677][SQL] Skip LikeSimplification rule if pattern contains any escapeChar #30625
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3718,6 +3718,20 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark | |
} | ||
} | ||
} | ||
|
||
test("SPARK-33677: LikeSimplification should be skipped if pattern contains any escapeChar") { | ||
withTable("string_tbl") { | ||
sql("CREATE TABLE string_tbl USING parquet SELECT 'm@ca' AS s") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could you use a temporary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is no temporary table in spark, you mean temporary view? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yea, I meant a temporary view... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @luluorta have you tried temp view? AFAIK There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works if I use DataFrame to create temp view. |
||
|
||
val e = intercept[AnalysisException] { | ||
sql("SELECT s LIKE 'm%@ca' ESCAPE '%' FROM string_tbl").collect() | ||
} | ||
assert(e.message.contains("the pattern 'm%@ca' is invalid, " + | ||
"the escape character is not allowed to precede '@'")) | ||
|
||
checkAnswer(sql("SELECT s LIKE 'm@@ca' ESCAPE '@' FROM string_tbl"), Row(true)) | ||
} | ||
} | ||
} | ||
|
||
case class Foo(bar: Option[String]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct me if I was wrong: we need to make sure this rule doesn't change result. If the pattern is invalid,
Like
should fail. However, it's expensive to validate the pattern (need to compile it). Here we usep.contains(escapeChar)
as a shortcut to know if the pattern might be invalid.Can we add some comments to explain it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done