You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/09/26 00:47:15 UTC

[GitHub] [spark] srowen commented on a change in pull request #34086: [SPARK-36836][SQL] Fix incorrect result in `sha2` expression

srowen commented on a change in pull request #34086:
URL: https://github.com/apache/spark/pull/34086#discussion_r716117546



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala
##########
@@ -134,8 +137,10 @@ case class Sha2(left: Expression, right: Expression)
         if ($eval2 == 224) {
           try {
             java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-224");
-            md.update($eval1);
-            ${ev.value} = UTF8String.fromBytes(md.digest());
+            byte[] messageDigest = md.digest($eval1);
+            String hashText = new java.math.BigInteger(1, messageDigest).toString(16);
+            String paddedHashText = String.format("%56s", hashText).replace(' ', '0');

Review comment:
       How about using this same code above to ensure consistency?




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