Skip to content
Merged
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
Next Next commit
chore: Add comment about zero value validation
Signed-off-by: zlatan.el <[email protected]>
  • Loading branch information
km-zlatan-el committed Dec 19, 2022
commit e0c952f97b81af85720e4c467d3b30607b02e3c2
1 change: 1 addition & 0 deletions sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def _python_value_to_proto_value(
) = PYTHON_SCALAR_VALUE_TYPE_TO_PROTO_VALUE[feast_value_type]
if valid_scalar_types:
if sample == 0 or sample == 0.0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would you mind adding a comment indicating why this special case is necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e0c952f Left the comment. Let me know if it is not inappropriate!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kysersozelee hm I think this comment is still not super clear to me - it would be great if you could add why type validation cannot be performed with only one type (if I understand correctly from #3400, the issue is because you might e.g. have an int value in a float column)

Copy link
Copy Markdown
Contributor Author

@kysersozelee kysersozelee Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixwang9817

Left the two comments. Let me know if it is inappropriate!

# Numpy convert 0 to int. However, in the feature view definition, the type of column may be a float.
# So, if value is 0, type validation must pass if scalar_types are either int or float.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @kysersozelee!

# In the case of a value of 0, type validation cannot be performed with only one int or float type.
assert type(sample) in [np.int64, np.float64, float, int]
else:
assert type(sample) in valid_scalar_types
Expand Down