nikolamand-db commented on code in PR #46180: URL: https://github.com/apache/spark/pull/46180#discussion_r1606750756
########## common/unsafe/src/test/scala/org/apache/spark/unsafe/types/CollationFactorySuite.scala: ########## @@ -30,31 +33,95 @@ import org.apache.spark.unsafe.types.UTF8String.{fromString => toUTF8} class CollationFactorySuite extends AnyFunSuite with Matchers { // scalastyle:ignore funsuite test("collationId stability") { - val utf8Binary = fetchCollation(0) + assert(INDETERMINATE_COLLATION_ID == -1) + + assert(UTF8_BINARY_COLLATION_ID == 0) + val utf8Binary = fetchCollation(UTF8_BINARY_COLLATION_ID) assert(utf8Binary.collationName == "UTF8_BINARY") assert(utf8Binary.supportsBinaryEquality) - val utf8BinaryLcase = fetchCollation(1) + assert(UTF8_BINARY_LCASE_COLLATION_ID == 1) + val utf8BinaryLcase = fetchCollation(UTF8_BINARY_LCASE_COLLATION_ID) assert(utf8BinaryLcase.collationName == "UTF8_BINARY_LCASE") assert(!utf8BinaryLcase.supportsBinaryEquality) - val unicode = fetchCollation(2) + assert(UNICODE_COLLATION_ID == (1 << 29)) + val unicode = fetchCollation(UNICODE_COLLATION_ID) assert(unicode.collationName == "UNICODE") - assert(unicode.supportsBinaryEquality); + assert(unicode.supportsBinaryEquality) - val unicodeCi = fetchCollation(3) + assert(UNICODE_CI_COLLATION_ID == ((1 << 29) | (1 << 17))) + val unicodeCi = fetchCollation(UNICODE_CI_COLLATION_ID) assert(unicodeCi.collationName == "UNICODE_CI") assert(!unicodeCi.supportsBinaryEquality) } - test("fetch invalid collation name") { - val error = intercept[SparkException] { - fetchCollation("UTF8_BS") + test("UTF8_BINARY and ICU root locale collation names") { + // collation name already normalized + Seq( + "UTF8_BINARY", + "UTF8_BINARY_LCASE", + "UNICODE", + "UNICODE_CI", + "UNICODE_AI", + "UNICODE_CI_AI" + ).foreach(collationName => { + val col = fetchCollation(collationName) + assert(col.collationName == collationName) + }) + // collation name normalization + Seq( + // ICU root locale + ("UNICODE_CS", "UNICODE"), + ("UNICODE_CS_AS", "UNICODE"), + ("UNICODE_CI_AS", "UNICODE_CI"), + ("UNICODE_AI_CS", "UNICODE_AI"), + ("UNICODE_AI_CI", "UNICODE_CI_AI"), + // randomized case collation names + ("utf8_binary", "UTF8_BINARY"), + ("UtF8_binARy_LcasE", "UTF8_BINARY_LCASE"), + ("unicode", "UNICODE"), + ("UnICoDe_cs_aI", "UNICODE_AI") + ).foreach{ + case (name, normalized) => + val col = fetchCollation(name) + assert(col.collationName == normalized) } + } + + test("fetch invalid UTF8_BINARY and ICU root locale collation names") { Review Comment: We already have these tests, please check https://github.com/apache/spark/pull/46180/files#diff-9c12d32db9d55dd6ecb5b10f2fc57c7ba7de7275cab57bf157fa42cbc09f3876R386-R397. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org