panbingkun commented on code in PR #47845:
URL: https://github.com/apache/spark/pull/47845#discussion_r1728878117
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -112,6 +113,50 @@ class CollationStringExpressionsSuite
})
}
+ test("Support `StringSplitSQL` string expression with collation") {
+ case class SplitPartTestCase[R](
+ str: String,
+ delimiter: String,
+ collation: String,
+ result: R)
+ val testCases = Seq(
+ SplitPartTestCase("1a2", "a", "UTF8_BINARY", Array("1", "2")),
+ SplitPartTestCase("1a2", "a", "UNICODE", Array("1", "2")),
+ SplitPartTestCase("1a2", "A", "UTF8_LCASE", Array("1", "2")),
+ SplitPartTestCase("1a2", "A", "UNICODE_CI", Array("1", "2"))
+ )
+ testCases.foreach(t => {
+ // Unit test.
+ val str = Literal.create(t.str, StringType(t.collation))
+ val delimiter = Literal.create(t.delimiter, StringType(t.collation))
+ checkEvaluation(StringSplitSQL(str, delimiter), t.result)
+ })
+
+ // Because `StringSplitSQL` is an internal expression, E2E SQL test cannot
be performed.
+ checkError(
+ exception = intercept[AnalysisException] {
+ val expr = StringSplitSQL(
+ Cast(Literal.create("1a2"), StringType("UTF8_BINARY")),
+ Cast(Literal.create("a"), StringType("UTF8_LCASE")))
+ CollationTypeCasts.transform.apply(expr)
Review Comment:
`CollationTypeCasts.transform` is directly called here to test it
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]