From cc8a2e736a1c2da93db796d7c3b0ef736e647a95 Mon Sep 17 00:00:00 2001 From: carloea2 Date: Sun, 30 Aug 2026 22:58:02 -0600 Subject: [PATCH] fix(pyamber): hash large binary tuples --- amber/src/main/python/core/models/tuple.py | 3 +++ amber/src/test/python/core/models/test_tuple.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/amber/src/main/python/core/models/tuple.py b/amber/src/main/python/core/models/tuple.py index 1f319b6a4f4..9357bf0dd0d 100644 --- a/amber/src/main/python/core/models/tuple.py +++ b/amber/src/main/python/core/models/tuple.py @@ -474,6 +474,9 @@ def __hash__(self) -> int: 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.LARGE_BINARY: lambda f: int_32( + salt + java_hash_bytes(map(ord, f.uri), 0, 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 aff43faa881..693b26f01bb 100644 --- a/amber/src/test/python/core/models/test_tuple.py +++ b/amber/src/test/python/core/models/test_tuple.py @@ -561,6 +561,13 @@ def test_hash(self): ) assert hash(tuple5) == -2099556631 # calculated with Java + def test_hash_large_binary_matches_java(self): + from core.models.type.large_binary import largebinary + + schema = Schema(raw_schema={"blob": "LARGE_BINARY"}) + tuple_ = Tuple({"blob": largebinary("s3://bucket/key")}, schema) + assert hash(tuple_) == 1754254834 + def test_tuple_with_large_binary(self): """Test tuple with largebinary field.""" from core.models.type.large_binary import largebinary