You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2026/04/17 17:19:05 UTC

(spark) branch master updated: [SPARK-56492][SQL][TEST][FOLLOWUP] Use hardcoded expected values in HashExpressionsSuite sha2 tests

This is an automated email from the ASF dual-hosted git repository.

dongjoon-hyun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new b1f04e62bc03 [SPARK-56492][SQL][TEST][FOLLOWUP] Use hardcoded expected values in HashExpressionsSuite sha2 tests
b1f04e62bc03 is described below

commit b1f04e62bc037c5d0b2678ecbcfb3abb7a8cf97d
Author: Liang-Chi Hsieh <vi...@gmail.com>
AuthorDate: Fri Apr 17 10:18:53 2026 -0700

    [SPARK-56492][SQL][TEST][FOLLOWUP] Use hardcoded expected values in HashExpressionsSuite sha2 tests
    
    ### What changes were proposed in this pull request?
    
    Replace dynamically computed expected values with hardcoded hex strings in sha2 tests so the tests independently verify correctness instead of being tautological (testing `f(x) == f(x)`).
    
    ### Why are the changes needed?
    
    The previous test used the same JavaUtils methods to compute expected values, making it tautological (f(x) == f(x)). Hardcoded values ensure the tests independently verify correctness.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    Unit test
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code
    
    Closes #55365 from viirya/SPARK-56492-hardcode-hash-test-values.
    
    Authored-by: Liang-Chi Hsieh <vi...@gmail.com>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .../spark/sql/catalyst/expressions/HashExpressionsSuite.scala | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala
index c1d44e945899..7bb62e8a836c 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/HashExpressionsSuite.scala
@@ -26,7 +26,6 @@ import scala.language.implicitConversions
 import org.scalatest.exceptions.TestFailedException
 
 import org.apache.spark.SparkFunSuite
-import org.apache.spark.network.util.JavaUtils.{digestToHexString, sha256Hex}
 import org.apache.spark.sql.{RandomDataGenerator, Row}
 import org.apache.spark.sql.catalyst.InternalRow
 import org.apache.spark.sql.catalyst.encoders.{ExamplePointUDT, ExpressionEncoder}
@@ -65,13 +64,15 @@ class HashExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
     checkEvaluation(Sha2(Literal("ABC".getBytes(StandardCharsets.UTF_8)), Literal(224)),
       "107c5072b799c4771f328304cfe1ebb375eb6ea7f35a3aa753836fad")
     checkEvaluation(Sha2(Literal("ABC".getBytes(StandardCharsets.UTF_8)), Literal(0)),
-      sha256Hex("ABC"))
+      "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78")
     checkEvaluation(Sha2(Literal("ABC".getBytes(StandardCharsets.UTF_8)), Literal(256)),
-      sha256Hex("ABC"))
+      "b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78")
     checkEvaluation(Sha2(Literal.create(Array[Byte](1, 2, 3, 4, 5, 6), BinaryType), Literal(384)),
-      digestToHexString("SHA-384", Array[Byte](1, 2, 3, 4, 5, 6)))
+      "557cfe660c753b830efa61528fc350ef384a7a4b9d3467c6230049bc59548eb8" +
+        "a404874baff89cb0f9bd18400829fdc2")
     checkEvaluation(Sha2(Literal("ABC".getBytes(StandardCharsets.UTF_8)), Literal(512)),
-      digestToHexString("SHA-512", "ABC"))
+      "397118fdac8d83ad98813c50759c85b8c47565d8268bf10da483153b747a7474" +
+        "3a58a90e85aa9f705ce6984ffc128db567489817e4092d050d8a1cc596ddc119")
     // unsupported bit length
     checkEvaluation(Sha2(Literal.create(null, BinaryType), Literal(1024)), null)
     // null input and valid bit length


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