miland-db commented on code in PR #45615:
URL: https://github.com/apache/spark/pull/45615#discussion_r1535317953


##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -70,6 +71,34 @@ class CollationStringExpressionsSuite extends QueryTest with 
SharedSparkSession
     })
   }
 
+  case class RepeatCollationTestCase[R](s: String, n: Int, collation: String, 
expectedResult: R)
+
+  test("Support Repeat string expression with Collation") {
+    // Supported collations
+    val checksRepeat = Seq(
+      RepeatCollationTestCase("Spark", 2, "UTF8_BINARY", "SparkSpark"),
+      RepeatCollationTestCase("Spark", 2, "UTF8_BINARY_LCASE", "SparkSpark"),
+      RepeatCollationTestCase("Spark", 2, "UNICODE", "SparkSpark"),
+      RepeatCollationTestCase("Spark", 2, "UNICODE_CI", "SparkSpark")
+    )
+    checksRepeat.foreach(ct => {
+      checkAnswer(sql(s"SELECT repeat(collate('${ct.s}', '${ct.collation}'), 
${ct.n})"),
+        Row(ct.expectedResult))
+    })
+
+    // Check return type
+    val checksReturnType = Seq(
+      RepeatCollationTestCase("Spark", 2, "UTF8_BINARY", "UTF8_BINARY"),
+      RepeatCollationTestCase("Spark", 2, "UTF8_BINARY_LCASE", 
"UTF8_BINARY_LCASE"),
+      RepeatCollationTestCase("Spark", 2, "UNICODE", "UNICODE"),
+      RepeatCollationTestCase("Spark", 2, "UNICODE_CI", "UNICODE_CI")
+    )
+    checksReturnType.foreach(ct => {
+      checkAnswer(sql(s"SELECT collation(repeat(collate('${ct.s}', 
'${ct.collation}'), ${ct.n}))"),

Review Comment:
   I have changed the tests now. Please check it again



-- 
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]

Reply via email to