Skip to content

Commit

Permalink
Fix __hash__
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
  • Loading branch information
felixwang9817 committed Apr 6, 2022
1 parent c59291b commit 995780a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sdk/python/feast/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def __eq__(self, other):
if self.name != other.name or self.dtype != other.dtype:
return False
return True

def __hash__(self):
return hash((id(self), self.name))
return hash((self.name, hash(self.dtype)))

def __lt__(self, other):
return self.name < other.name
Expand All @@ -72,7 +72,7 @@ def from_proto(cls, field_proto: FieldProto):
field_proto: FieldProto protobuf object
"""
return cls(name=field_proto.name, dtype=from_value_type(field_proto.value_type))

@classmethod
def from_feature(cls, feature: Feature):
"""
Expand Down
3 changes: 3 additions & 0 deletions sdk/python/feast/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def to_value_type(self) -> ValueTypeProto.Enum:
"""
raise NotImplementedError

def __hash__(self):
return hash(self.to_value_type())

def __eq__(self, other):
return self.to_value_type() == other.to_value_type()

Expand Down

0 comments on commit 995780a

Please sign in to comment.