You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OnlineResponse.to_arrow() returns a null-typed column when a feature is missing for every requested entity #7248
OnlineResponse.to_arrow() returns the same Arrow type for a feature on every call, whether or not the requested entities have a value for it.
Current Behavior
to_arrow() is pa.Table.from_pydict(self.to_dict()), so the column type is inferred from the returned values. When none of the requested entities has the feature in the online store (or the request has zero rows), every value is None and the column comes back as Arrow null:
# entity 1001 is materialized, 9999 is not
store.get_online_features(features=["driver_hourly_stats:conv_rate", "driver_hourly_stats:avg_daily_trips"],
entity_rows=[{"driver_id": 1001}]).to_arrow().schema
driver_id: int64
avg_daily_trips: int64
conv_rate: double
store.get_online_features(features=[...same...], entity_rows=[{"driver_id": 9999}]).to_arrow().schema
driver_id: int64
avg_daily_trips: null
conv_rate: null
So the schema of a serving batch depends on the data in it. Concatenating batches (pa.concat_tables) fails with a schema mismatch, and code that casts or validates the Arrow schema before feeding a model breaks on the batches where a feature happens to be missing for everyone, typically small batches of new entities.
Steps to reproduce
feast init demo && cd demo/feature_repo && feast apply && feast materialize-incremental <now>, then run the two calls above (any driver_id that is not in the data gives the null columns).
OnlineResponse already gets the requested features' value types (feature_types). When every value of a feature is missing, the column can be built with the Arrow type that to_arrow() infers for that value type when values are present (Int32/Int64 -> int64, Float32/Float64 -> double, String -> string, lists likewise), so the schema stays the same and columns with values are not affected. I have a PR for this.
Activity