nebojsa-db commented on code in PR #46561:
URL: https://github.com/apache/spark/pull/46561#discussion_r1601308123
##########
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 => {
+ val query = s"SELECT date_format(collate('${t.d}', '${t.c}'), '${t.f}')"
+ // Result & data type
+ checkAnswer(sql(query), Row(t.r))
+
assert(sql(query).schema.fields.head.dataType.sameType(SQLConf.get.defaultStringType))
Review Comment:
Done.
--
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]