GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Merge shared ODFV source projections in feature resolution by sanskar-singh-2403 · Pull Request #6622 · feast-dev/feast

fix: Merge shared ODFV source projections in feature resolution #6622

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.

Sign up for GitHub

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

Merged
ntkathole merged 1 commit into feast-dev:master from sanskar-singh-2403:fix/odfv-shared-source-projection-merge
Jul 30, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix: Merge shared ODFV source projections in feature resolution #6622

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
da47014
fix: Merge shared ODFV source projections in feature resolution
sanskar-singh-2403 Jul 25, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

41 changes: 36 additions & 5 deletions 41 sdk/python/feast/utils.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from feast.base_feature_view import BaseFeatureView
from feast.feature_service import FeatureService
from feast.feature_view import FeatureView
from feast.feature_view_projection import FeatureViewProjection
from feast.infra.registry.base_registry import BaseRegistry
from feast.on_demand_feature_view import OnDemandFeatureView

Expand Down Expand Up @@ -1193,6 +1194,19 @@ def _list_feature_views(
return feature_views


def _merge_projection_features(
target: "FeatureViewProjection",
other: "FeatureViewProjection",
) -> None:
existing_names = {feature.name for feature in target.features}
merged = list(target.features)
for feature in other.features:
if feature.name not in existing_names:
existing_names.add(feature.name)
merged.append(feature)
target.features = merged


def _get_feature_views_to_use(
registry: "BaseRegistry",
project,
Expand Down Expand Up @@ -1223,6 +1237,25 @@ def _get_feature_views_to_use(
feature_views = parsed # type: ignore[assignment]

fvs_to_use, od_fvs_to_use = [], []
fvs_by_projection_key: Dict[str, "FeatureView"] = {}

def _append_or_merge_source_fv(fv_with_projection: "FeatureView") -> None:
# Index every (source) feature view by its effective projection key so
# that a regular FeatureView and an ODFV source projection resolving to
# the same key are merged into a single entry instead of duplicated.
# Without this, requesting ["src_fv:a", "odfv_b:b_out"] where odfv_b
# sources src_fv appends two src_fv entries and later raises
# "KeyError: Feature a not found in projection src_fv".
projection_key = fv_with_projection.projection.name_to_use()
existing = fvs_by_projection_key.get(projection_key)
if existing is None:
fvs_by_projection_key[projection_key] = fv_with_projection
fvs_to_use.append(fv_with_projection)
else:
_merge_projection_features(
existing.projection, fv_with_projection.projection
)

for name, version_num, projection in feature_views:
if version_num is not None:
if not getattr(registry, "enable_online_versioning", False):
Expand Down Expand Up @@ -1286,10 +1319,8 @@ def _get_feature_views_to_use(
source_fv.entities = [] # type: ignore[attr-defined]
source_fv.entity_columns = [] # type: ignore[attr-defined]

if source_fv not in fvs_to_use:
fvs_to_use.append(
source_fv.with_projection(copy.copy(source_projection))
)
new_source_fv = source_fv.with_projection(copy.copy(source_projection))
_append_or_merge_source_fv(new_source_fv)
else:
if (
hide_dummy_entity
Expand All @@ -1302,7 +1333,7 @@ def _get_feature_views_to_use(
fv = fv.with_projection(copy.copy(projection))
if version_num is not None:
fv.projection.version_tag = version_num
fvs_to_use.append(fv)
_append_or_merge_source_fv(fv) # type: ignore[arg-type]

return (fvs_to_use, od_fvs_to_use)

Expand Down
174 changes: 174 additions & 0 deletions 174 sdk/python/tests/unit/test_utils.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,177 @@ def test_large_scale_correctness(self):
assert ts.seconds == expected_ts
for status in fv.statuses:
assert status == FieldStatus.PRESENT


class TestGetFeatureViewsToUseSharedSource:
def _build_store(self, data_dir):
import os
from datetime import timedelta

import pandas as pd

from feast import Entity, FeatureStore, FeatureView, Field, FileSource
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from feast.on_demand_feature_view import on_demand_feature_view
from feast.repo_config import RepoConfig
from feast.types import Float64

driver = Entity(name="driver", join_keys=["driver_id"])

df = pd.DataFrame(
{
"driver_id": [1001, 1002],
"event_timestamp": [
datetime(2024, 1, 1, 10, 0, 0, tzinfo=timezone.utc),
datetime(2024, 1, 1, 11, 0, 0, tzinfo=timezone.utc),
],
"created": [
datetime(2024, 1, 1, 10, 0, 0, tzinfo=timezone.utc),
datetime(2024, 1, 1, 11, 0, 0, tzinfo=timezone.utc),
],
"a": [1.0, 2.0],
"b": [10.0, 20.0],
}
)
src_path = os.path.join(data_dir, "src.parquet")
df.to_parquet(path=src_path, allow_truncated_timestamps=True)

src = FileSource(
name="src_source",
path=src_path,
timestamp_field="event_timestamp",
created_timestamp_column="created",
)

src_fv = FeatureView(
name="src_fv",
entities=[driver],
ttl=timedelta(days=0),
schema=[
Field(name="a", dtype=Float64),
Field(name="b", dtype=Float64),
],
online=True,
source=src,
)

@on_demand_feature_view(
sources=[src_fv[["a"]]],
schema=[Field(name="a_out", dtype=Float64)],
mode="pandas",
)
def odfv_a(inputs):
return pd.DataFrame({"a_out": inputs["a"] + 1})

@on_demand_feature_view(
sources=[src_fv[["b"]]],
schema=[Field(name="b_out", dtype=Float64)],
mode="pandas",
)
def odfv_b(inputs):
return pd.DataFrame({"b_out": inputs["b"] + 100})

store = FeatureStore(
config=RepoConfig(
project="test_shared_source",
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")
),
)
)
store.apply([driver, src, src_fv, odfv_a, odfv_b])
return store

def test_shared_source_projections_are_merged(self):
import tempfile

from feast.utils import _get_feature_views_to_use

with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as data_dir:
store = self._build_store(data_dir)

fvs, odfvs = _get_feature_views_to_use(
store.registry,
store.project,
["odfv_a:a_out", "odfv_b:b_out"],
)

src_entries = [fv for fv in fvs if fv.projection.name_to_use() == "src_fv"]
assert len(src_entries) == 1
projected = sorted(
feature.name for feature in src_entries[0].projection.features
)
assert projected == ["a", "b"]
assert {odfv.name for odfv in odfvs} == {"odfv_a", "odfv_b"}

def test_regular_fv_and_odfv_source_are_merged(self):
# Regression: a regular FeatureView requested alongside an ODFV that
# sources it must resolve to a single, merged src_fv entry. Previously
# the regular FV was appended but not indexed in fvs_by_projection_key,
# so the ODFV source appended a second partial src_fv projection and a
# later lookup raised "KeyError: Feature a not found in projection
# src_fv".
import tempfile

from feast.utils import _get_feature_views_to_use

with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as data_dir:
store = self._build_store(data_dir)

fvs, odfvs = _get_feature_views_to_use(
store.registry,
store.project,
["src_fv:a", "odfv_b:b_out"],
)

src_entries = [fv for fv in fvs if fv.projection.name_to_use() == "src_fv"]
assert len(src_entries) == 1
projected = sorted(
feature.name for feature in src_entries[0].projection.features
)
assert projected == ["a", "b"]
assert {odfv.name for odfv in odfvs} == {"odfv_b"}

def test_regular_fv_and_odfv_source_merge_order_independent(self):
import tempfile

from feast.utils import _get_feature_views_to_use

with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as data_dir:
store = self._build_store(data_dir)

fvs, _ = _get_feature_views_to_use(
store.registry,
store.project,
["odfv_b:b_out", "src_fv:a"],
)

src_entries = [fv for fv in fvs if fv.projection.name_to_use() == "src_fv"]
assert len(src_entries) == 1
projected = sorted(
feature.name for feature in src_entries[0].projection.features
)
assert projected == ["a", "b"]

def test_shared_source_ref_order_independent(self):
import tempfile

from feast.utils import _get_feature_views_to_use

with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as data_dir:
store = self._build_store(data_dir)

fvs, _ = _get_feature_views_to_use(
store.registry,
store.project,
["odfv_b:b_out", "odfv_a:a_out"],
)
src_entries = [fv for fv in fvs if fv.projection.name_to_use() == "src_fv"]
assert len(src_entries) == 1
projected = sorted(
feature.name for feature in src_entries[0].projection.features
)
assert projected == ["a", "b"]
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.