Skip to content

Commit 995780a

Browse files
committed
Fix __hash__
Signed-off-by: Felix Wang <[email protected]>
1 parent c59291b commit 995780a

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎sdk/python/feast/field.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def __eq__(self, other):
4646
if self.name != other.name or self.dtype != other.dtype:
4747
return False
4848
return True
49-
49+
5050
def __hash__(self):
51-
return hash((id(self), self.name))
51+
return hash((self.name, hash(self.dtype)))
5252

5353
def __lt__(self, other):
5454
return self.name < other.name
@@ -72,7 +72,7 @@ def from_proto(cls, field_proto: FieldProto):
7272
field_proto: FieldProto protobuf object
7373
"""
7474
return cls(name=field_proto.name, dtype=from_value_type(field_proto.value_type))
75-
75+
7676
@classmethod
7777
def from_feature(cls, feature: Feature):
7878
"""

‎sdk/python/feast/types.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def to_value_type(self) -> ValueTypeProto.Enum:
4646
"""
4747
raise NotImplementedError
4848

49+
def __hash__(self):
50+
return hash(self.to_value_type())
51+
4952
def __eq__(self, other):
5053
return self.to_value_type() == other.to_value_type()
5154

0 commit comments

Comments
 (0)