Skip to content

Commit 481f3aa

Browse files
committed
feat: Add optional 'org' in feature view (feast-dev#6288)
Signed-off-by: Nick Quinn <[email protected]>
1 parent f630056 commit 481f3aa

4 files changed

Lines changed: 71 additions & 1 deletion

File tree

‎protos/feast/core/FeatureView.proto‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ message FeatureView {
3636
FeatureViewMeta meta = 2;
3737
}
3838

39-
// Next available id: 19
39+
// Next available id: 20
4040
// TODO(adchia): refactor common fields from this and ODFV into separate metadata proto
4141
message FeatureViewSpec {
4242
// Name of the feature view. Must be unique. Not updated.
@@ -97,6 +97,9 @@ message FeatureViewSpec {
9797

9898
// User-specified version pin (e.g. "latest", "v2", "version2")
9999
string version = 18;
100+
101+
// Organizational unit that owns this feature view (e.g. "ads", "search").
102+
string org = 19;
100103
}
101104

102105
message FeatureViewMeta {

‎sdk/python/feast/batch_feature_view.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def __init__(
9393
offline: bool = False,
9494
description: str = "",
9595
owner: str = "",
96+
org: str = "",
9697
schema: Optional[List[Field]] = None,
9798
udf: Optional[Callable[[Any], Any]] = None,
9899
udf_string: Optional[str] = "",
@@ -151,6 +152,7 @@ def __init__(
151152
offline=offline,
152153
description=description,
153154
owner=owner,
155+
org=org,
154156
schema=schema,
155157
source=source, # type: ignore[arg-type]
156158
sink_source=sink_source,

‎sdk/python/feast/feature_view.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class FeatureView(BaseFeatureView):
107107
description: str
108108
tags: Dict[str, str]
109109
owner: str
110+
org: str
110111
materialization_intervals: List[Tuple[datetime, datetime]]
111112
mode: Optional[Union["TransformationMode", str]]
112113
enable_validation: bool
@@ -125,6 +126,7 @@ def __init__(
125126
description: str = "",
126127
tags: Optional[Dict[str, str]] = None,
127128
owner: str = "",
129+
org: str = "",
128130
mode: Optional[Union["TransformationMode", str]] = None,
129131
enable_validation: bool = False,
130132
version: str = "latest",
@@ -152,6 +154,8 @@ def __init__(
152154
tags (optional): A dictionary of key-value pairs to store arbitrary metadata.
153155
owner (optional): The owner of the feature view, typically the email of the
154156
primary maintainer.
157+
org (optional): The organizational unit that owns this feature view
158+
(e.g. "ads", "search").
155159
mode (optional): The transformation mode for feature transformations. Only meaningful
156160
when transformations are applied. Choose from TransformationMode enum values.
157161
enable_validation (optional): If True, enables schema validation during materialization
@@ -278,6 +282,7 @@ def __init__(
278282
owner=owner,
279283
source=self.batch_source,
280284
)
285+
self.org = org
281286
self.online = online
282287
self.offline = offline
283288
self.mode = mode
@@ -302,6 +307,7 @@ def __copy__(self):
302307
version=self.version,
303308
description=self.description,
304309
owner=self.owner,
310+
org=self.org,
305311
)
306312

307313
# This is deliberately set outside of the FV initialization as we do not have the Entity objects.
@@ -355,6 +361,7 @@ def __eq__(self, other):
355361
or self.enable_validation != other.enable_validation
356362
or normalize_version_string(self.version)
357363
!= normalize_version_string(other.version)
364+
or self.org != other.org
358365
):
359366
return False
360367

@@ -485,6 +492,7 @@ def to_proto_spec(
485492
description=self.description,
486493
tags=self.tags,
487494
owner=self.owner,
495+
org=self.org,
488496
ttl=(ttl_duration if ttl_duration is not None else None),
489497
online=self.online,
490498
offline=self.offline,
@@ -615,6 +623,7 @@ def _from_proto_internal(
615623
description=feature_view_proto.spec.description,
616624
tags=dict(feature_view_proto.spec.tags),
617625
owner=feature_view_proto.spec.owner,
626+
org=feature_view_proto.spec.org,
618627
online=feature_view_proto.spec.online,
619628
offline=feature_view_proto.spec.offline,
620629
ttl=(
@@ -637,6 +646,7 @@ def _from_proto_internal(
637646
description=feature_view_proto.spec.description,
638647
tags=dict(feature_view_proto.spec.tags),
639648
owner=feature_view_proto.spec.owner,
649+
org=feature_view_proto.spec.org,
640650
online=feature_view_proto.spec.online,
641651
offline=feature_view_proto.spec.offline,
642652
ttl=(

‎sdk/python/tests/unit/test_feature_views.py‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,3 +542,58 @@ def simple_udf(df: pd.DataFrame) -> pd.DataFrame:
542542
assert deserialized.feature_transformation is not None, (
543543
"Expected transformation to be present"
544544
)
545+
546+
547+
def test_feature_view_org_field():
548+
"""Test that the optional `org` field is stored, serialized, and round-trips correctly."""
549+
file_source = FileSource(name="my-file-source", path="test.parquet")
550+
551+
# org is optional — defaults to empty string
552+
fv_no_org = FeatureView(
553+
name="fv-no-org",
554+
entities=[],
555+
schema=[Field(name="feature1", dtype=Float32)],
556+
source=file_source,
557+
)
558+
assert fv_no_org.org == ""
559+
560+
# org can be set explicitly
561+
fv_with_org = FeatureView(
562+
name="fv-with-org",
563+
entities=[],
564+
schema=[Field(name="feature1", dtype=Float32)],
565+
source=file_source,
566+
org="ads",
567+
)
568+
assert fv_with_org.org == "ads"
569+
570+
# org is serialized to proto
571+
proto = fv_with_org.to_proto()
572+
assert proto.spec.org == "ads"
573+
574+
# org survives a proto round-trip
575+
roundtripped = FeatureView.from_proto(proto)
576+
assert roundtripped.org == "ads"
577+
578+
# a view without org round-trips to empty string
579+
proto_no_org = fv_no_org.to_proto()
580+
assert proto_no_org.spec.org == ""
581+
roundtripped_no_org = FeatureView.from_proto(proto_no_org)
582+
assert roundtripped_no_org.org == ""
583+
584+
# equality respects org
585+
fv_org_a = FeatureView(
586+
name="fv-eq",
587+
entities=[],
588+
schema=[Field(name="feature1", dtype=Float32)],
589+
source=file_source,
590+
org="ads",
591+
)
592+
fv_org_b = FeatureView(
593+
name="fv-eq",
594+
entities=[],
595+
schema=[Field(name="feature1", dtype=Float32)],
596+
source=file_source,
597+
org="search",
598+
)
599+
assert fv_org_a != fv_org_b

0 commit comments

Comments
 (0)