dbatomic commented on code in PR #44968:
URL: https://github.com/apache/spark/pull/44968#discussion_r1476405059


##########
common/unsafe/src/test/scala/org/apache/spark/unsafe/types/CollationFactorySuite.scala:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.unsafe.types
+
+import org.apache.spark.SparkException
+// scalastyle:off
+import org.scalatest.funsuite.AnyFunSuite
+import org.scalatest.matchers.must.Matchers
+
+import org.apache.spark.sql.catalyst.util.CollationFactory._
+import org.apache.spark.unsafe.types.UTF8String.{fromString => toUTF8}
+
+class CollationFactorySuite extends AnyFunSuite with Matchers { // 
scalastyle:ignore funsuite
+  test("collationId stability") {
+    val ucsBasic = fetchCollation(0)
+    assert(ucsBasic.collationName == "UCS_BASIC")
+    assert(ucsBasic.isBinaryCollation)
+
+    val ucsBasicLcase = fetchCollation(1)
+    assert(ucsBasicLcase.collationName == "UCS_BASIC_LCASE")
+    assert(!ucsBasicLcase.isBinaryCollation)
+
+    val unicode = fetchCollation(2)
+    assert(unicode.collationName == "UNICODE")
+    assert(unicode.isBinaryCollation);
+
+    val unicodeCi = fetchCollation(3)
+    assert(unicodeCi.collationName == "UNICODE_CI")
+    assert(!unicodeCi.isBinaryCollation)
+  }
+
+  test("fetch invalid collation name") {
+    val error = intercept[SparkException] {
+      fetchCollation("UCS_BASIS")
+    }
+
+    assert(error.getMessage.contains(
+      "The value UCS_BASIS does not represent a correct collation name."))
+    assert(error.getMessage.contains("Suggested valid collation name: 
[UCS_BASIC]"))

Review Comment:
   This suite is in `common` so I can't reference `SparkFunSuite` which is in 
`core`. I already had the same discussion with Wenchen in another comment 
thread. These tests are derived from pure `AnyFunSuite` (same as other scala 
tests under `common`.
   
   Once we add `CollationSuite` in core catalyst and open surface area for 
collations I will add the proper `checkError` tests there. That should take 
care of other languages as well.



-- 
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]

Reply via email to