From 793eeeea5242979c39d9793da08436ee75a772b3 Mon Sep 17 00:00:00 2001 From: Chaitany Patel Date: Tue, 24 Nov 2026 16:30:42 +0530 Subject: [PATCH 1/4] fix: Keep Python on demand features when full feature names are requested With full_feature_names=True, online retrieval asks for an on demand feature as "__". Pandas mode renames the UDF's outputs to that form in transform_arrow, but transform_dict, used by Python mode, returned them under their bare names, so none matched the request and the features were dropped from the response without an error. Give transform_dict the same full_feature_names argument and output renaming as transform_arrow, and pass it from online retrieval. Signed-off-by: Chaitany Patel --- sdk/python/feast/on_demand_feature_view.py | 13 +++++++++++++ sdk/python/feast/utils.py | 2 +- .../unit/test_on_demand_python_transformation.py | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/sdk/python/feast/on_demand_feature_view.py b/sdk/python/feast/on_demand_feature_view.py index 3fff495c204..5903a492052 100644 --- a/sdk/python/feast/on_demand_feature_view.py +++ b/sdk/python/feast/on_demand_feature_view.py @@ -1092,6 +1092,7 @@ def _postprocess_arrow_table( def transform_dict( self, feature_dict: dict[str, Any], # type: ignore + full_feature_names: bool = False, ) -> dict[str, Any]: """ Transform a dictionary of features using the configured transformation. @@ -1099,6 +1100,8 @@ def transform_dict( Args: feature_dict: Dictionary containing input features + full_feature_names: Name each output feature "__", + as :meth:`transform_arrow` does, instead of by its bare name. Returns: Dictionary with transformed features @@ -1122,6 +1125,16 @@ def transform_dict( if feature_name in output_dict: del output_dict[feature_name] + # The UDF names its outputs as it likes; rename them to match what the + # caller asked for, like _postprocess_arrow_table does. + for feature in self.features: + short_name = feature.name + long_name = self._get_projected_feature_name(short_name) + if full_feature_names and short_name in output_dict: + output_dict[long_name] = output_dict.pop(short_name) + elif not full_feature_names and long_name in output_dict: + output_dict[short_name] = output_dict.pop(long_name) + return output_dict def _preprocess_feature_dict( diff --git a/sdk/python/feast/utils.py b/sdk/python/feast/utils.py index e09577de110..78e091520c8 100644 --- a/sdk/python/feast/utils.py +++ b/sdk/python/feast/utils.py @@ -1012,7 +1012,7 @@ def _is_metrics_active(): if k not in undeclared_columns } transformed_features_dict: Dict[str, List[Any]] = odfv.transform_dict( - odfv_input_dict + odfv_input_dict, full_feature_names ) elif odfv.mode in {"pandas", "substrait"}: if initial_response_arrow is None: diff --git a/sdk/python/tests/unit/test_on_demand_python_transformation.py b/sdk/python/tests/unit/test_on_demand_python_transformation.py index 522c0c53a39..f717931859a 100644 --- a/sdk/python/tests/unit/test_on_demand_python_transformation.py +++ b/sdk/python/tests/unit/test_on_demand_python_transformation.py @@ -345,6 +345,22 @@ def test_python_pandas_parity(self): + online_python_response["acc_rate"][0] ) + def test_python_view_with_full_feature_names(self): + response = self.store.get_online_features( + entity_rows=[{"driver_id": 1001}], + features=[ + "driver_hourly_stats:conv_rate", + "driver_hourly_stats:acc_rate", + "python_view:conv_rate_plus_acc_python", + ], + full_feature_names=True, + ).to_dict() + + assert response["python_view__conv_rate_plus_acc_python"] == [ + response["driver_hourly_stats__conv_rate"][0] + + response["driver_hourly_stats__acc_rate"][0] + ] + def test_python_docs_demo(self): entity_rows = [ { From f5b810ce7b94bdbc99e3363a708954d2b7357637 Mon Sep 17 00:00:00 2001 From: Chaitany Patel Date: Tue, 24 Nov 2026 16:41:57 +0530 Subject: [PATCH 2/4] fix: Accept proto values for request data in online retrieval get_online_features takes entity values as proto Values, which is how the Python gRPC feature server passes a request's RepeatedValue map. Join keys convert because their type is known and proto Values pass through, but request data for an on demand feature view has no declared type, and inferring one from a proto Value raised "Value with native type value cannot be converted into Feast value type". Every gRPC request for an on demand feature view with a request source failed. When the type is unknown and the values are already proto Values, take the type from the field the proto sets and pass the values through. Signed-off-by: Chaitany Patel --- sdk/python/feast/type_map.py | 6 +++++- sdk/python/tests/unit/test_type_map.py | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sdk/python/feast/type_map.py b/sdk/python/feast/type_map.py index 53680908eca..b0be39e06e4 100644 --- a/sdk/python/feast/type_map.py +++ b/sdk/python/feast/type_map.py @@ -1570,7 +1570,11 @@ def python_values_to_proto_values( value_type = feature_type sample = next(filter(_non_empty_value, values), None) # first not empty value if sample is not None and feature_type == ValueType.UNKNOWN: - if isinstance(sample, (list, np.ndarray)): + if isinstance(sample, ProtoValue): + # Already converted, e.g. request data from a gRPC RepeatedValue: + # the field it sets names the type, and the values pass through. + value_type = _proto_value_to_value_type(sample) + elif isinstance(sample, (list, np.ndarray)): value_type = ( feature_type if len(sample) == 0 diff --git a/sdk/python/tests/unit/test_type_map.py b/sdk/python/tests/unit/test_type_map.py index e240f46fed2..02409854870 100644 --- a/sdk/python/tests/unit/test_type_map.py +++ b/sdk/python/tests/unit/test_type_map.py @@ -47,6 +47,14 @@ def test_null_unix_timestamp(): assert converted is None +def test_proto_values_pass_through_without_a_known_type(): + # Request data from a gRPC request arrives as proto Values, with no type + # declared for it among the entities. + protos = [ProtoValue(string_val="s1"), ProtoValue(string_val="s2")] + + assert python_values_to_proto_values(protos, ValueType.UNKNOWN) == protos + + def test_null_unix_timestamp_list(): """Test that UnixTimestamp lists with a null get converted from proto correctly.""" From 84c1fd1ab1b9e180605a8bb0b0df306da74b39be Mon Sep 17 00:00:00 2001 From: Chaitany Patel Date: Wed, 25 Nov 2026 12:27:51 +0530 Subject: [PATCH 3/4] fix: Keep on demand feature types with full feature names With full_feature_names=True, online retrieval selects an on demand feature by its "__" name, but looked up its declared type by the bare name. The lookup missed, so the values were converted with an inferred type: a batch of empty arrays raised "Couldn't infer value type from empty value", and Python floats in an Array(Float32) came back as a double list. Key the type lookup by the same name used to select the output. Signed-off-by: Chaitany Patel --- sdk/python/feast/utils.py | 9 +++- .../test_on_demand_python_transformation.py | 42 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/sdk/python/feast/utils.py b/sdk/python/feast/utils.py index 78e091520c8..60d3ac7efc9 100644 --- a/sdk/python/feast/utils.py +++ b/sdk/python/feast/utils.py @@ -1054,7 +1054,14 @@ def _is_metrics_active(): selected_subset = [f for f in transformed_columns if f in _feature_refs] proto_values = [] - schema_dict = {k.name: k.dtype for k in odfv.schema} + schema_dict = { + ( + odfv._get_projected_feature_name(k.name) + if full_feature_names + else k.name + ): k.dtype + for k in odfv.schema + } for selected_feature in selected_subset: feature_vector = transformed_features[selected_feature] selected_feature_type = schema_dict.get(selected_feature, None) diff --git a/sdk/python/tests/unit/test_on_demand_python_transformation.py b/sdk/python/tests/unit/test_on_demand_python_transformation.py index f717931859a..7d89cd97b1b 100644 --- a/sdk/python/tests/unit/test_on_demand_python_transformation.py +++ b/sdk/python/tests/unit/test_on_demand_python_transformation.py @@ -846,6 +846,48 @@ def python_view(inputs: dict[str, Any]) -> dict[str, Any]: store.apply([request_source, python_view]) +@pytest.mark.parametrize("full_feature_names", [False, True]) +def test_python_view_keeps_its_declared_type_in_both_naming_modes( + full_feature_names, +): + with tempfile.TemporaryDirectory() as data_dir: + store = FeatureStore( + config=RepoConfig( + project="test_on_demand_python_transformation", + registry=os.path.join(data_dir, "registry.db"), + provider="local", + entity_key_serialization_version=3, + online_store=SqliteOnlineStoreConfig( + path=os.path.join(data_dir, "online.db") + ), + ) + ) + request_source = RequestSource( + name="match_request", schema=[Field(name="match_count", dtype=Int64)] + ) + + @on_demand_feature_view( + sources=[request_source], + schema=[Field(name="matches", dtype=Array(Float32))], + mode="python", + ) + def match_view(inputs: dict[str, Any]) -> dict[str, Any]: + return {"matches": [[1.5] * n for n in inputs["match_count"]]} + + store.apply([request_source, match_view]) + + def value_kind(match_count: int) -> str: + response = store.get_online_features( + features=["match_view:matches"], + entity_rows=[{"match_count": match_count}], + full_feature_names=full_feature_names, + ) + return response.proto.results[-1].values[0].WhichOneof("val") + + assert value_kind(0) == "float_list_val" + assert value_kind(1) == "float_list_val" + + @pytest.mark.skipif( not ( sys.version_info[0:2] in [(3, 10), (3, 11)] From efa8dc8aeafdd601a6ba84aaf49ba81f50886a4a Mon Sep 17 00:00:00 2001 From: Chaitany Patel Date: Wed, 25 Nov 2026 12:59:38 +0530 Subject: [PATCH 4/4] test: Cover the on demand retrieval fixes with one test Replace the three tests with one: a Python-mode view with an Array(Float32) output, read with full feature names, with its request data passed as a proto Value, returning an empty list. It fails without any one of the three fixes. Signed-off-by: Chaitany Patel --- .../test_on_demand_python_transformation.py | 71 +++++-------------- sdk/python/tests/unit/test_type_map.py | 8 --- 2 files changed, 19 insertions(+), 60 deletions(-) diff --git a/sdk/python/tests/unit/test_on_demand_python_transformation.py b/sdk/python/tests/unit/test_on_demand_python_transformation.py index 7d89cd97b1b..2175a0efa3d 100644 --- a/sdk/python/tests/unit/test_on_demand_python_transformation.py +++ b/sdk/python/tests/unit/test_on_demand_python_transformation.py @@ -25,6 +25,7 @@ from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig from feast.nlp_test_data import create_document_chunks_df from feast.on_demand_feature_view import on_demand_feature_view +from feast.protos.feast.types.Value_pb2 import Value as ProtoValue from feast.types import ( Array, Bool, @@ -346,20 +347,28 @@ def test_python_pandas_parity(self): ) def test_python_view_with_full_feature_names(self): + request_source = RequestSource( + name="match_request", schema=[Field(name="match_count", dtype=Int64)] + ) + + @on_demand_feature_view( + sources=[request_source], + schema=[Field(name="matches", dtype=Array(Float32))], + mode="python", + ) + def match_view(inputs: dict[str, Any]) -> dict[str, Any]: + return {"matches": [[1.5] * n for n in inputs["match_count"]]} + + self.store.apply([request_source, match_view]) response = self.store.get_online_features( - entity_rows=[{"driver_id": 1001}], - features=[ - "driver_hourly_stats:conv_rate", - "driver_hourly_stats:acc_rate", - "python_view:conv_rate_plus_acc_python", - ], + features=["match_view:matches"], + # The Python gRPC server passes request data as proto Values. + entity_rows=[{"match_count": ProtoValue(int64_val=0)}], full_feature_names=True, ).to_dict() - assert response["python_view__conv_rate_plus_acc_python"] == [ - response["driver_hourly_stats__conv_rate"][0] - + response["driver_hourly_stats__acc_rate"][0] - ] + # An empty list converts only with its declared type, found by the long name. + assert response["match_view__matches"] == [[]] def test_python_docs_demo(self): entity_rows = [ @@ -846,48 +855,6 @@ def python_view(inputs: dict[str, Any]) -> dict[str, Any]: store.apply([request_source, python_view]) -@pytest.mark.parametrize("full_feature_names", [False, True]) -def test_python_view_keeps_its_declared_type_in_both_naming_modes( - full_feature_names, -): - with tempfile.TemporaryDirectory() as data_dir: - store = FeatureStore( - config=RepoConfig( - project="test_on_demand_python_transformation", - registry=os.path.join(data_dir, "registry.db"), - provider="local", - entity_key_serialization_version=3, - online_store=SqliteOnlineStoreConfig( - path=os.path.join(data_dir, "online.db") - ), - ) - ) - request_source = RequestSource( - name="match_request", schema=[Field(name="match_count", dtype=Int64)] - ) - - @on_demand_feature_view( - sources=[request_source], - schema=[Field(name="matches", dtype=Array(Float32))], - mode="python", - ) - def match_view(inputs: dict[str, Any]) -> dict[str, Any]: - return {"matches": [[1.5] * n for n in inputs["match_count"]]} - - store.apply([request_source, match_view]) - - def value_kind(match_count: int) -> str: - response = store.get_online_features( - features=["match_view:matches"], - entity_rows=[{"match_count": match_count}], - full_feature_names=full_feature_names, - ) - return response.proto.results[-1].values[0].WhichOneof("val") - - assert value_kind(0) == "float_list_val" - assert value_kind(1) == "float_list_val" - - @pytest.mark.skipif( not ( sys.version_info[0:2] in [(3, 10), (3, 11)] diff --git a/sdk/python/tests/unit/test_type_map.py b/sdk/python/tests/unit/test_type_map.py index 02409854870..e240f46fed2 100644 --- a/sdk/python/tests/unit/test_type_map.py +++ b/sdk/python/tests/unit/test_type_map.py @@ -47,14 +47,6 @@ def test_null_unix_timestamp(): assert converted is None -def test_proto_values_pass_through_without_a_known_type(): - # Request data from a gRPC request arrives as proto Values, with no type - # declared for it among the entities. - protos = [ProtoValue(string_val="s1"), ProtoValue(string_val="s2")] - - assert python_values_to_proto_values(protos, ValueType.UNKNOWN) == protos - - def test_null_unix_timestamp_list(): """Test that UnixTimestamp lists with a null get converted from proto correctly."""