aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-10-07 18:10:20 -0700
committerJakob Odersky <jakob@odersky.com>2016-10-07 18:10:29 -0700
commitc76fad30a5f41b8da8a6a90d568bf81d3fff84f8 (patch)
treef67834dd7083f71540cd9a62dec3bcbdc26125dc
parent5f190eb49e2a70131637a1c439a73066cf612069 (diff)
downloadspark-c76fad30a5f41b8da8a6a90d568bf81d3fff84f8.tar.gz
spark-c76fad30a5f41b8da8a6a90d568bf81d3fff84f8.tar.bz2
spark-c76fad30a5f41b8da8a6a90d568bf81d3fff84f8.zip
Add more tests for various combinations of backslashes and SQL pattern characters
-rw-r--r--sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala14
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala
index 9b42489cb2..9316f76190 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala
@@ -55,6 +55,20 @@ class RegexpExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation("a\nb" like "a%b", true)
checkEvaluation("""\\\\""" like """%\\%""", true) // triple quotes to avoid java string escaping
+ checkEvaluation("""\_%""" like """%\\__""", true)
+ checkEvaluation("""\_%""" like "%\\\\__", true)
+ checkEvaluation("""\_%""" like """%\\_%""", true)
+ checkEvaluation("""\\\\%%""" like """\\%""", true)
+ checkEvaluation("""\%\""" like """%\%%""", true)
+ checkEvaluation("\\\n\n%\\" like "\\\\___\\\\", true)
+ checkEvaluation("""%%""" like """%%""", true)
+ checkEvaluation("""\__""" like """\\\__""", true)
+
+ checkEvaluation("""\\\__""" like """%\\%\%""", false)
+ checkEvaluation("""\_""" like """\_\_""", false)
+ checkEvaluation("""_\\\%""" like """%\\""", false)
+ checkEvaluation("""_\\__""" like """_\___""", false)
+
}
test("LIKE Non-literal Regular Expression") {