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

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-8250-e6e621796b3e99add765bc82510aa363aebf8c05
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 716ab3c1e834350332c83753357440ec7e27c39d
Author: carloea2 <[email protected]>
AuthorDate: Sun Nov 15 13:28:30 2026 +0000

    feat(pyamber): match Java binary hashes (#8250)
    
    ### What changes were proposed in this PR?
    
    Python tuple hashing now converts binary field bytes to signed Java byte
    values before applying the array hash. Existing values below `0x80`
    remain unchanged.
    
    ### Any related issues, documentation, discussions?
    
    Closes #8249
    
    ### How was this PR tested?
    
    ```text
    python -c "import sys,pytest; 
sys.path[:0]=[r'C:\Users\carlo\texera\texera-worktrees\investigate-bug61\amber\src\main\python',r'C:\Users\carlo\texera\texera\amber\src\main\python'];
 raise 
SystemExit(pytest.main(['amber/src/test/python/core/models/test_tuple.py::TestTuple::test_hash_binary_with_high_byte_matches_java','amber/src/test/python/core/architecture/sendsemantics/test_partitioners.py','-q','-p','no:cacheprovider']))"
    36 passed
    
    ruff check amber/src/main/python amber/src/test/python
    All checks passed
    
    ruff format --check amber/src/main/python amber/src/test/python
    213 files already formatted
    ```
    
    Direct reproduction after the fix:
    
    ```text
    61
    ```
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Codex
---
 amber/src/main/python/core/models/tuple.py      | 4 +++-
 amber/src/test/python/core/models/test_tuple.py | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/amber/src/main/python/core/models/tuple.py 
b/amber/src/main/python/core/models/tuple.py
index 1f319b6a4f..52be14642c 100644
--- a/amber/src/main/python/core/models/tuple.py
+++ b/amber/src/main/python/core/models/tuple.py
@@ -473,7 +473,9 @@ class Tuple:
             AttributeType.DOUBLE: lambda f: java_hash_long(double_to_long(f)),
             AttributeType.STRING: lambda f: java_hash_bytes(map(ord, f), 0, 
salt),
             AttributeType.TIMESTAMP: lambda f: 
java_hash_long(int(f.timestamp())),
-            AttributeType.BINARY: lambda f: java_hash_bytes(f, 1, salt),
+            AttributeType.BINARY: lambda f: java_hash_bytes(
+                (b if b < 128 else b - 256 for b in f), 1, salt
+            ),
         }
 
         for name, field in self.as_key_value_pairs():
diff --git a/amber/src/test/python/core/models/test_tuple.py 
b/amber/src/test/python/core/models/test_tuple.py
index aff43faa88..f0d9c4950d 100644
--- a/amber/src/test/python/core/models/test_tuple.py
+++ b/amber/src/test/python/core/models/test_tuple.py
@@ -561,6 +561,10 @@ class TestTuple:
         )
         assert hash(tuple5) == -2099556631  # calculated with Java
 
+    def test_hash_binary_with_high_byte_matches_java(self):
+        schema = Schema(raw_schema={"data": "BINARY"})
+        assert hash(Tuple({"data": b"\xff"}, schema)) == 61
+
     def test_tuple_with_large_binary(self):
         """Test tuple with largebinary field."""
         from core.models.type.large_binary import largebinary

Reply via email to