GideonPotok commented on code in PR #46040:
URL: https://github.com/apache/spark/pull/46040#discussion_r1568822574


##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -212,6 +212,49 @@ class CollationStringExpressionsSuite
     })
   }
 
+  test("Support Left/Right/Substr with collation") {
+    case class SubstringTestCase(query: String, collation: String, result: Row)
+    val checks = Seq("utf8_binary_lcase", "utf8_binary", "unicode", 
"unicode_ci").flatMap(
+      c => Seq(
+        SubstringTestCase("select substr('example' collate " + c + ", 1, 
100)", c, Row("example")),
+        SubstringTestCase("select substr('example' collate " + c + ", 2, 2)", 
c, Row("xa")),
+        SubstringTestCase("select substr('example' collate " + c + ", 0, 0)", 
c, Row("")),
+        SubstringTestCase("select substr('example' collate " + c + ", -3, 2)", 
c, Row("pl")),
+        SubstringTestCase("select substr(' a世a ' collate " + c + ", 2, 3)", c, 
Row("a世a")), // scalastyle:ignore
+        SubstringTestCase("select left(' a世a ' collate " + c + ", 3)", c, 
Row(" a世")), // scalastyle:ignore
+        SubstringTestCase("select right(' a世a ' collate " + c + ", 3)", c, 
Row("世a ")), // scalastyle:ignore
+        SubstringTestCase("select left('AaAaAaAa000000' collate " + c + ", 
3)", c, Row("AaA")),
+        SubstringTestCase("select right('AaAaAaAa000000' collate " + c + ", 
3)", c, Row("000")),
+        SubstringTestCase("select substr('' collate " + c + ", 1, 1)", c, 
Row("")),
+        SubstringTestCase("select left('' collate " + c + ", 1)", c, Row("")),
+        SubstringTestCase("select right('' collate " + c + ", 1)", c, Row("")),
+        // improper values
+        SubstringTestCase("select left(null collate " + c + ", 1)", c, 
Row(null)),
+        SubstringTestCase("select right(null collate " + c + ", 1)", c, 
Row(null)),
+        SubstringTestCase("select substr(null collate " + c + ", 1)", c, 
Row(null)),
+        SubstringTestCase("select substr(null collate " + c + ", 1, 1)", c, 
Row(null)),
+        SubstringTestCase("select left(null collate " + c + ", null)", c, 
Row(null)),
+        SubstringTestCase("select right(null collate " + c + ", null)", c, 
Row(null)),
+        SubstringTestCase("select substr(null collate " + c + ", null)", c, 
Row(null)),
+        SubstringTestCase("select substr(null collate " + c + ", null, null)", 
c, Row(null)),
+        SubstringTestCase("select left('AaAaAaAa000000' collate " + c + ", 
null)", c, Row(null)),
+        SubstringTestCase("select right('AaAaAaAa000000' collate " + c + ", 
null)", c, Row(null)),
+        SubstringTestCase("select substr('AaAaAaAa000000' collate " + c + ", 
null)", c, Row(null)),
+        SubstringTestCase("select substr('AaAaAaAa0' collate " + c + ", null, 
null)", c, Row(null)),
+        SubstringTestCase("select right('' collate " + c + ", null)", c, 
Row(null)),
+        SubstringTestCase("select substr('' collate " + c + ", null)", c, 
Row(null)),
+        SubstringTestCase("select substr('' collate " + c + ", null, null)", 
c, Row(null)),
+        SubstringTestCase("select left('' collate " + c + ", null)", c, 
Row(null))

Review Comment:
   @uros-db done. Please re-review



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to