uros-db commented on code in PR #46041: URL: https://github.com/apache/spark/pull/46041#discussion_r1565545434
########## 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") { Review Comment: ```suggestion test("Support StringRPad string expressions with collation") { ``` -- 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