You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "mkaravel (via GitHub)" <gi...@apache.org> on 2024/06/06 05:18:55 UTC

Re: [PR] [WIP][SPARK-48435][SQL] UNICODE collation should not support binary equality [spark]

mkaravel commented on code in PR #46772:
URL: https://github.com/apache/spark/pull/46772#discussion_r1628787249


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollationExpressionSuite.scala:
##########
@@ -174,10 +174,10 @@ class CollationExpressionSuite extends SparkFunSuite with ExpressionEvalHelper {
       ("aa", "UTF8_BINARY_LCASE", UTF8String.fromString("aa").getBytes),
       ("AA", "UTF8_BINARY_LCASE", UTF8String.fromString("aa").getBytes),
       ("aA", "UTF8_BINARY_LCASE", UTF8String.fromString("aa").getBytes),
-      ("", "UNICODE", UTF8String.fromString("").getBytes),
-      ("aa", "UNICODE", UTF8String.fromString("aa").getBytes),
-      ("AA", "UNICODE", UTF8String.fromString("AA").getBytes),
-      ("aA", "UNICODE", UTF8String.fromString("aA").getBytes),
+      ("", "UNICODE", Array[Byte](1, 1, 0)),
+      ("aa", "UNICODE", Array[Byte](42, 42, 1, 6, 1, 6, 0)),
+      ("AA", "UNICODE", Array[Byte](42, 42, 1, 6, 1, -36, -36, 0)),
+      ("aA", "UNICODE", Array[Byte](42, 42, 1, 6, 1, -59, -36, 0)),

Review Comment:
   nit: I can see that you have been using the same format for UNICODE_CI, so it makes sense to use the same representation. However, I think it would be more easy to follow if a hex representation was used instead of the integer representation (especially for the negative values, I think it is more intuitive to write them in hex form, especially given the fact that we are talking about bytes)



##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollationExpressionSuite.scala:
##########
@@ -174,10 +174,10 @@ class CollationExpressionSuite extends SparkFunSuite with ExpressionEvalHelper {
       ("aa", "UTF8_BINARY_LCASE", UTF8String.fromString("aa").getBytes),
       ("AA", "UTF8_BINARY_LCASE", UTF8String.fromString("aa").getBytes),
       ("aA", "UTF8_BINARY_LCASE", UTF8String.fromString("aa").getBytes),
-      ("", "UNICODE", UTF8String.fromString("").getBytes),
-      ("aa", "UNICODE", UTF8String.fromString("aa").getBytes),
-      ("AA", "UNICODE", UTF8String.fromString("AA").getBytes),
-      ("aA", "UNICODE", UTF8String.fromString("aA").getBytes),
+      ("", "UNICODE", Array[Byte](1, 1, 0)),
+      ("aa", "UNICODE", Array[Byte](42, 42, 1, 6, 1, 6, 0)),
+      ("AA", "UNICODE", Array[Byte](42, 42, 1, 6, 1, -36, -36, 0)),
+      ("aA", "UNICODE", Array[Byte](42, 42, 1, 6, 1, -59, -36, 0)),

Review Comment:
   nit: I can see that you have been using the same format for UNICODE_CI, so it makes sense to use the same representation. However, I think it would be more easy to follow if a hex representation was used instead of the integer representation (especially for the negative values, I think it is more intuitive to write them in hex form, especially given the fact that we are talking about bytes).



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org