Skip to content

Commit

Permalink
fix: Assertion condition when value is 0 (feast-dev#3401)
Browse files Browse the repository at this point in the history
* fix: Add assertion condition when value is 0

Signed-off-by: zlatan.el <[email protected]>

* chore: Add comment about zero value validation

Signed-off-by: zlatan.el <[email protected]>

* chore: Modifiy the comment

Signed-off-by: zlatan.el <[email protected]>

* chore: Add the comment

Signed-off-by: zlatan.el <[email protected]>

Signed-off-by: zlatan.el <[email protected]>
Co-authored-by: zlatan.el <[email protected]>
Signed-off-by: franciscojavierarceo <[email protected]>
  • Loading branch information
2 people authored and franciscojavierarceo committed Jan 4, 2023
1 parent 0ab3942 commit cd9dc81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,12 @@ def _python_value_to_proto_value(
valid_scalar_types,
) = PYTHON_SCALAR_VALUE_TYPE_TO_PROTO_VALUE[feast_value_type]
if valid_scalar_types:
assert type(sample) in valid_scalar_types
if sample == 0 or sample == 0.0:
# 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.
assert type(sample) in [np.int64, int, np.float64, float]
else:
assert type(sample) in valid_scalar_types
if feast_value_type == ValueType.BOOL:
# ProtoValue does not support conversion of np.bool_ so we need to convert it to support np.bool_.
return [
Expand Down

0 comments on commit cd9dc81

Please sign in to comment.