Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15398#discussion_r84579527
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/RegexpExpressionsSuite.scala
 ---
    @@ -53,6 +57,40 @@ class RegexpExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
         checkEvaluation("a\nb" like "a_b", true)
         checkEvaluation("ab" like "a%b", true)
         checkEvaluation("a\nb" like "a%b", true)
    +
    +    // empty input
    +    checkEvaluation("" like "", true)
    +    checkEvaluation("a" like "", false)
    +    checkEvaluation("" like "a", false)
    +
    +    // SI-17647 double-escaping backslash
    +    checkEvaluation("""\\\\""" like """%\\%""", true) // triple quotes to 
avoid java string escaping
    +    checkEvaluation("""%%""" like """%%""", true)
    +    checkEvaluation("""\__""" like """\\\__""", true)
    +    checkEvaluation("""\\\__""" like """%\\%\%""", false)
    +    checkEvaluation("""_\\\%""" like """%\\""", false)
    +
    +    // unicode
    +    // scalastyle:off nonascii
    +    checkEvaluation("a\u20ACa" like "_\u20AC_", true)
    +    checkEvaluation("a€a" like "_€_", true)
    +    checkEvaluation("a€a" like "_\u20AC_", true)
    +    checkEvaluation("a\u20ACa" like "_€_", true)
    +    // scalastyle:on nonascii
    +
    +    // invalid escaping
    +    intercept[AnalysisException] {
    +      evaluate("""a""" like """\a""")
    +    }
    +    intercept[AnalysisException] {
    +      evaluate("""a""" like """a\""")
    +    }
    --- End diff --
    
    For these two invalid cases, you also need to check the error messages. For 
example,
    ```Scala
        val e = intercept[AnalysisException] {
          evaluate("""a""" like """\a""")
        }.getMessage
        assert(e.contains("xyz"))
    ```
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to