Skip to content

Commit 7073e37

Browse files
authored
feat: add __hash__ property for JSONArrowType (#316)
1 parent d9992fc commit 7073e37

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

db_dtypes/json.py

+3
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ def __arrow_ext_serialize__(self) -> bytes:
274274
def __arrow_ext_deserialize__(cls, storage_type, serialized) -> JSONArrowType:
275275
return JSONArrowType()
276276

277+
def __hash__(self) -> int:
278+
return hash(str(self))
279+
277280
def to_pandas_dtype(self):
278281
return JSONDtype()
279282

tests/unit/test_json.py

+5
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ def test_json_arrow_storage_type():
129129
assert pa.types.is_string(arrow_json_type.storage_type)
130130

131131

132+
def test_json_arrow_hash():
133+
arr = pa.array([], type=db_dtypes.JSONArrowType())
134+
assert hash(arr.type) == hash(db_dtypes.JSONArrowType())
135+
136+
132137
def test_json_arrow_constructors():
133138
data = [
134139
json.dumps(value, sort_keys=True, separators=(",", ":"))

0 commit comments

Comments
 (0)