cloud-fan commented on code in PR #45963:
URL: https://github.com/apache/spark/pull/45963#discussion_r1560358232
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -89,6 +89,73 @@ class CollationStringExpressionsSuite
testRepeat("UNICODE_CI", 3, "abc", 2)
}
+ test("Levenshtein expressions with collation") {
+ def prepareLevenshtein(
+ left: String,
+ right: String,
+ collation: String): Levenshtein = {
+ val collationId = CollationFactory.collationNameToId(collation)
+ val leftLit = Literal.create(left, StringType(collationId))
+ val rightLit = Literal.create(right, StringType(collationId))
+ Levenshtein(leftLit, rightLit)
+ }
+
+ Seq(
+ // scalastyle:off nonascii
+ CollationTestCase("", "", "UTF8_BINARY", 0),
+ CollationTestCase("", "something", "UTF8_BINARY", 9),
+ CollationTestCase("a", "a", "UTF8_BINARY", 0),
+ CollationTestCase("a", "A", "UTF8_BINARY", 1),
+ CollationTestCase("a", "a", "UTF8_BINARY_LCASE", 0),
+ CollationTestCase("a", "A", "UTF8_BINARY_LCASE", 0),
+ CollationTestCase("bd", "ABc", "UTF8_BINARY_LCASE", 2),
+ CollationTestCase("Xü", "Ü", "UTF8_BINARY_LCASE", 1),
+ CollationTestCase("Xũ", "Üx", "UTF8_BINARY_LCASE", 2),
+ CollationTestCase("", "something", "UTF8_BINARY_LCASE", 9),
+ CollationTestCase("sOmeThINg", "SOMETHING", "UTF8_BINARY_LCASE", 0),
+ CollationTestCase("sOmeThINg", "SOMETHING", "UNICODE", 5),
+ CollationTestCase("sOmeThINg", "SOMETHING", "UNICODE_CI", 0)
+ // scalastyle:on nonascii
+ ).foreach(c => checkEvaluation(prepareLevenshtein(c.s1, c.s2,
c.collation), c.expectedResult))
+ }
+
Review Comment:
Yea we need both unit tests and end-to-end tests
--
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]