uros-db commented on code in PR #47502:
URL: https://github.com/apache/spark/pull/47502#discussion_r1694815403
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala:
##########
@@ -620,6 +620,29 @@ class HashExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
checkHiveHashForDecimal("123456.123456789012345678901234567890", 38, 31,
1728235666)
}
+ for (collation <- Seq("UTF8_LCASE", "UNICODE_CI", "UTF8_BINARY")) {
+ test(s"hash equality for collated $collation strings") {
+ val s1 = "aaa"
+ val s2 = "AAA"
+
+ if (CollationFactory.fetchCollation(collation).supportsBinaryEquality) {
+ // Calculate interpreted hash values for s1 and s2
+ val interpretedHash1 = Murmur3Hash(Seq(Collate(Literal(s1),
collation)), 42).eval()
+ val interpretedHash2 = Murmur3Hash(Seq(Collate(Literal(s2),
collation)), 42).eval()
+
+ assert(interpretedHash1 != interpretedHash2)
+ } else {
+ // Interpreted hash value for s1
+ val interpretedHash = Murmur3Hash(Seq(Collate(Literal(s1),
collation)), 42).eval()
+
+ // Check if interpreted hash value is same as codegen for s1
+ checkEvaluation(Murmur3Hash(Seq(Collate(Literal(s1), collation)), 42),
interpretedHash)
Review Comment:
`checkEvaluation` will check both the interpreted path and gencode, so we
should be able to just do:
```
val hashExpr = Murmur3Hash(Seq(Collate(Literal(s1), collation)),
42).eval()
checkEvaluation(hashExpr, expectedHash)
```
--
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]