Skip to content

Commit 98a24a3

Browse files
fix: Assertion condition when value is 0 (#3401)
* 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]>
1 parent 0ab3942 commit 98a24a3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sdk/python/feast/type_map.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,12 @@ def _python_value_to_proto_value(
402402
valid_scalar_types,
403403
) = PYTHON_SCALAR_VALUE_TYPE_TO_PROTO_VALUE[feast_value_type]
404404
if valid_scalar_types:
405-
assert type(sample) in valid_scalar_types
405+
if sample == 0 or sample == 0.0:
406+
# Numpy convert 0 to int. However, in the feature view definition, the type of column may be a float.
407+
# So, if value is 0, type validation must pass if scalar_types are either int or float.
408+
assert type(sample) in [np.int64, int, np.float64, float]
409+
else:
410+
assert type(sample) in valid_scalar_types
406411
if feast_value_type == ValueType.BOOL:
407412
# ProtoValue does not support conversion of np.bool_ so we need to convert it to support np.bool_.
408413
return [

0 commit comments

Comments
 (0)