stefankandic commented on code in PR #46561:
URL: https://github.com/apache/spark/pull/46561#discussion_r1598605527
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -959,6 +959,37 @@ class CollationStringExpressionsSuite
assert(collationMismatch.getErrorClass ===
"DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE")
}
+ test("DateFormat string expression with collation") {
+ case class DateFormatTestCase[R](d: String, f: String, c: String, r: R)
+ val testCases = Seq(
+ DateFormatTestCase("2021-01-01", "yyyy-MM-dd", "UTF8_BINARY",
"2021-01-01"),
+ DateFormatTestCase("2021-01-01", "yyyy-dd", "UTF8_BINARY_LCASE",
"2021-01"),
+ DateFormatTestCase("2021-01-01", "yyyy-MM-dd", "UNICODE", "2021-01-01"),
+ DateFormatTestCase("2021-01-01", "yyyy", "UNICODE_CI", "2021")
+ )
+
+ testCases.foreach(t => {
Review Comment:
instead of writing all cases manually maybe think about doing this like:
```scala
for {
collateFirstArgument <- Seq(true, false)
collateSecondArgument <- Seq(true, false)
} {
val firstArgument = if (collateFirstArgument) s"collate('${t.d}',
'${t.c}')" else s"'${t.d}'"
...
}
```
--
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]