Skip to content

Commit

Permalink
Add return type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miland-db committed Mar 20, 2024
1 parent 79abfc1 commit 3047a3c
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,28 @@ class CollationStringExpressionsSuite extends QueryTest with SharedSparkSession

test("Support Repeat string expression with Collation") {
// Supported collations
val checks = Seq(
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"),
)
checks.foreach(ct => {
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}))"),
Row(ct.expectedResult))
})
}

// TODO: Add more tests for other string expressions
Expand Down

0 comments on commit 3047a3c

Please sign in to comment.