Visitar URL original
fix: Return python mode ODFV features with full feature names by breken-ai · Pull Request #6900 · feast-dev/feast · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: Return python mode ODFV features with full feature names
With full_feature_names=True the requested ODFV refs are
"<view>__<feature>", but transform_dict returns the UDF's short output
names. Nothing matched, so python mode (batch and singleton) ODFV
features were silently missing from get_online_features, while pandas
mode worked because transform_arrow renames its outputs.

Rename python mode outputs to the projected names, and look up the
declared schema type under those names too.

Signed-off-by: breken-ai <312387581+breken-ai@users.noreply.github.com>
  • Loading branch information
breken-ai committed Oct 8, 2026
commit 78eb277253ecfd1f90348aa44814c06dcc1ef51c
19 changes: 19 additions & 0 deletions sdk/python/feast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,18 @@ def _is_metrics_active():
transformed_features_dict: Dict[str, List[Any]] = odfv.transform_dict(
odfv_input_dict
)
if full_feature_names:
# The UDF returns short output names, but the requested refs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the renaming into transform_dict by adding full_feature_names parameter. It makes the three transform methods consistent and prevents the bug from recurring if transform_dict gets called from anywhere else.

# use "<view>__<feature>" (transform_arrow renames the same way).
odfv_output_names = {f.name for f in odfv.features}
transformed_features_dict = {
(
odfv._get_projected_feature_name(name)
if name in odfv_output_names
else name
): values
for name, values in transformed_features_dict.items()
}
elif odfv.mode in {"pandas", "substrait"}:
if initial_response_arrow is None:
initial_response_arrow = initial_response.to_arrow()
Expand Down Expand Up @@ -1032,6 +1044,13 @@ def _is_metrics_active():

proto_values = []
schema_dict = {k.name: k.dtype for k in odfv.schema}
if full_feature_names:
schema_dict.update(
{
odfv._get_projected_feature_name(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)
Expand Down
37 changes: 37 additions & 0 deletions sdk/python/tests/unit/test_on_demand_python_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,43 @@ def test_python_pandas_parity(self):
+ online_python_response["acc_rate"][0]
)

def test_python_views_with_full_feature_names(self):
online_response = self.store.get_online_features(
entity_rows=[{"driver_id": 1001}],
features=[
"driver_hourly_stats:conv_rate",
"driver_hourly_stats:acc_rate",
"pandas_view:conv_rate_plus_acc_pandas",
"python_demo_view:conv_rate_plus_val1_python",
"python_singleton_view:conv_rate_plus_acc_python_singleton",
],
full_feature_names=True,
).to_dict()

assert sorted(online_response.keys()) == sorted(
[
"driver_id",
"driver_hourly_stats__conv_rate",
"driver_hourly_stats__acc_rate",
"pandas_view__conv_rate_plus_acc_pandas",
"python_demo_view__conv_rate_plus_val1_python",
"python_singleton_view__conv_rate_plus_acc_python_singleton",
]
)
expected = (
online_response["driver_hourly_stats__conv_rate"][0]
+ online_response["driver_hourly_stats__acc_rate"][0]
)
assert online_response["pandas_view__conv_rate_plus_acc_pandas"] == [
pytest.approx(expected)
]
assert online_response["python_demo_view__conv_rate_plus_val1_python"] == [
pytest.approx(expected)
]
assert online_response[
"python_singleton_view__conv_rate_plus_acc_python_singleton"
] == [pytest.approx(expected)]

def test_python_docs_demo(self):
entity_rows = [
{
Expand Down