Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix __hash__
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
  • Loading branch information
felixwang9817 committed Apr 6, 2022
commit 995780a4a155d4918ae2c3f94e713e976b6e2762
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