uros-db commented on code in PR #45643:
URL: https://github.com/apache/spark/pull/45643#discussion_r1565490452
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationStringExpressionsSuite.scala:
##########
@@ -96,6 +95,107 @@ class CollationStringExpressionsSuite
assert(collationMismatch.getErrorClass === "COLLATION_MISMATCH.EXPLICIT")
}
+ test("INSTR check result on explicitly collated strings") {
+ def testInStr(str: String, substr: String, collationId: Integer, expected:
Integer): Unit = {
+ val string = Literal.create(str, StringType(collationId))
+ val substring = Literal.create(substr, StringType(collationId))
+
+ checkEvaluation(StringInstr(string, substring), expected)
+ }
+
+ var collationId = CollationFactory.collationNameToId("UTF8_BINARY")
+ testInStr("aaads", "Aa", collationId, 0)
+ testInStr("aaaDs", "de", collationId, 0)
+ testInStr("aaads", "ds", collationId, 4)
+ testInStr("xxxx", "", collationId, 1)
+ testInStr("", "xxxx", collationId, 0)
+ // scalastyle:off
+ testInStr("test大千世界X大千世界", "大千", collationId, 5)
+ testInStr("test大千世界X大千世界", "界X", collationId, 8)
+ // scalastyle:on
+
+ collationId = CollationFactory.collationNameToId("UTF8_BINARY_LCASE")
+ testInStr("aaads", "Aa", collationId, 1)
+ testInStr("aaaDs", "de", collationId, 0)
+ testInStr("aaaDs", "ds", collationId, 4)
+ testInStr("xxxx", "", collationId, 1)
+ testInStr("", "xxxx", collationId, 0)
+ // scalastyle:off
+ testInStr("test大千世界X大千世界", "大千", collationId, 5)
+ testInStr("test大千世界X大千世界", "界x", collationId, 8)
+ // scalastyle:on
+
+ collationId = CollationFactory.collationNameToId("UNICODE")
+ testInStr("aaads", "Aa", collationId, 0)
+ testInStr("aaads", "aa", collationId, 1)
+ testInStr("aaads", "de", collationId, 0)
+ testInStr("xxxx", "", collationId, 1)
+ testInStr("", "xxxx", collationId, 0)
+ // scalastyle:off
+ testInStr("test大千世界X大千世界", "界x", collationId, 0)
+ testInStr("test大千世界X大千世界", "界X", collationId, 8)
+ // scalastyle:on
+
+ collationId = CollationFactory.collationNameToId("UNICODE_CI")
+ testInStr("aaads", "AD", collationId, 3)
+ testInStr("aaads", "dS", collationId, 4)
+ // scalastyle:off
+ testInStr("test大千世界X大千世界", "界x", collationId, 8)
+ // scalastyle:on
+ }
+
+ test("FIND_IN_SET check result on explicitly collated strings") {
+ def testFindInSet(word: String, set: String, collationId: Integer,
expected: Integer): Unit = {
+ val w = Literal.create(word, StringType(collationId))
+ val s = Literal.create(set, StringType(collationId))
+
+ checkEvaluation(FindInSet(w, s), expected)
+ }
Review Comment:
we shouldn't use unit tests like this, please take a look at the other tests
in their appropriate suites:
- CollationSupportSuite.java for unit tests related to newly introduced
collation-aware support in CollationSupport.java
- CollationStringExpressionsSuite.scala for e2e SQL tests that should be
used in limited quantity
read more in the refactor Jira ticket description notes:
https://issues.apache.org/jira/browse/SPARK-47410
--
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]