Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
beauchbum opened this issue Jan 19, 2023 · 0 comments · Fixed by #3452
Closed

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

beauchbum opened this issue Jan 19, 2023 · 0 comments · Fixed by #3452

Comments

@beauchbum
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant