Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions amber/src/main/python/core/models/tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 7 additions & 0 deletions amber/src/test/python/core/models/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading