Skip to content

0.28.0 Python SDK: Assertion failure on Boolean types in type_map.py #3443 #3451

@beauchbum

Description

@beauchbum

Expected Behavior

In Snowflake
select FEAST_FEAST_FEATURES_SNOWFLAKE_BOOLEAN_TO_BOOL_PROTO(FALSE);
--> 3800

Current Behavior

select FEAST_FEAST_FEATURES_SNOWFLAKE_BOOLEAN_TO_BOOL_PROTO(FALSE);

Traceback (most recent call last):
  File "/home/udf/6137508531934/feast.zip/feast/infra/utils/snowflake/snowpark/snowflake_udfs.py", line 150, in feast_snowflake_boolean_to_bool_boolean_proto
    python_values_to_proto_values(df[0].to_numpy(), ValueType.BOOL),
  File "/home/udf/6137508531934/feast.zip/feast/type_map.py", line 454, in python_values_to_proto_values
    return _python_value_to_proto_value(value_type, values)
  File "/home/udf/6137508531934/feast.zip/feast/type_map.py", line 408, in _python_value_to_proto_value
    assert type(sample) in [np.int64, int, np.float64, float]
AssertionError
 in function FEAST_FEAST_FEATURES_SNOWFLAKE_BOOLEAN_TO_BOOL_PROTO with handler feast.infra.utils.snowflake.snowpark.snowflake_udfs.feast_snowflake_boolean_to_bool_boolean_proto

Steps to reproduce

  • feast==0.28.0
  • Batch materialization job where Boolean values (must include FALSE)

Specifications

  • Version: 0.28.0
  • Platform: mac, linux
  • Subsystem: ?

Possible Solution

As pointed out in this issue, I believe this bug was introduced in 0.28.0 such that:

Boolean value evaluates to

(
field_name,
func,
valid_scalar_types,
) = PYTHON_SCALAR_VALUE_TYPE_TO_PROTO_VALUE[feast_value_type]

ValueType.BOOL: ("bool_val", lambda x: x, {bool, np.bool_}),

Which causes it to enter this conditional

if 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

Where it can fail if sample == False because False == 0 --> True

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions