uros-db commented on code in PR #46041:
URL: https://github.com/apache/spark/pull/46041#discussion_r1565545698
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -163,6 +163,48 @@ class CollationStringExpressionsSuite
})
}
+ test("Support Lpad string expressions with collation") {
+ // Supported collations
+ case class PadTestCase[R](s: String, len: Int, pad: String, c: String,
result: R)
+ val testCases = Seq(
+ PadTestCase("", 5, " ", "UTF8_BINARY", " "),
+ PadTestCase("abc", 5, " ", "UNICODE", " abc"),
+ PadTestCase("abc", 5, "XY", "UTF8_BINARY_LCASE", "XYabc"),
+ PadTestCase("abc", 5, "123", "UNICODE_CI", "12abc"),
+ PadTestCase("abc", 2, " ", "UTF8_BINARY", "ab"),
+ PadTestCase("abc", 2, "XY", "UNICODE", "ab"),
+ PadTestCase("abc", 2, "123", "UTF8_BINARY_LCASE", "ab"),
+ PadTestCase("abc", 2, "123", "UNICODE_CI", "ab")
+ )
+ testCases.foreach(t => {
+ val query = s"SELECT lpad(collate('${t.s}', '${t.c}'), ${t.len},
'${t.pad}')"
+ // Result & data type
+ checkAnswer(sql(query), Row(t.result))
+ assert(sql(query).schema.fields.head.dataType.sameType(StringType(t.c)))
+ })
+ }
+
+ test("Support Rpad string expressions with collation") {
+ // Supported collations
+ case class PadTestCase[R](s: String, len: Int, pad: String, c: String,
result: R)
Review Comment:
```suggestion
case class StringRPadTestCase[R](s: String, len: Int, pad: String, c:
String, result: R)
```
--
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]