Skip to content

Commit 528724c

Browse files
authored
Move Project field to Table/View spec (#1388)
* Move Project field to Table/View spec Signed-off-by: Willem Pienaar <git@willem.co> * Change field number feature table Signed-off-by: Willem Pienaar <git@willem.co> * Move project out of Entity object into spec Signed-off-by: Willem Pienaar <git@willem.co>
1 parent 31f118e commit 528724c

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

protos/feast/core/DataSource.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ message DataSource {
6565
message BigQueryOptions {
6666
// Full table reference in the form of [project:dataset.table]
6767
string table_ref = 1;
68+
69+
// SQL query that returns a table containing feature data. Must contain an event_timestamp column, and respective
70+
// entity columns
71+
string query = 2;
6872
}
6973

7074
// Defines options for DataSource that sources features from Kafka messages.

protos/feast/core/Entity.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ message Entity {
2929
EntitySpecV2 spec = 1;
3030
// System-populated metadata for this entity.
3131
EntityMeta meta = 2;
32-
string project = 3;
3332
}
3433

3534
message EntitySpecV2 {
3635
// Name of the entity.
3736
string name = 1;
3837

38+
// Name of Feast project that this feature table belongs to.
39+
string project = 9;
40+
3941
// Type of the entity.
4042
feast.types.ValueType.Enum value_type = 2;
4143

protos/feast/core/FeatureTable.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ message FeatureTable {
3434

3535
// System-populated metadata for this feature table.
3636
FeatureTableMeta meta = 2;
37-
string project = 3;
3837
}
3938

4039
message FeatureTableSpec {
4140
// Name of the feature table. Must be unique. Not updated.
4241
string name = 1;
42+
43+
// Name of Feast project that this feature table belongs to.
44+
string project = 9;
4345

4446
// List names of entities to associate with the Features defined in this
4547
// Feature Table. Not updatable.

protos/feast/core/FeatureView.proto

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,40 @@ import "feast/core/DataSource.proto";
2828
import "feast/core/Feature.proto";
2929

3030
message FeatureView {
31-
// User-specified specifications of this feature table.
31+
// User-specified specifications of this feature view.
3232
FeatureViewSpec spec = 1;
3333

34-
// System-populated metadata for this feature table.
34+
// System-populated metadata for this feature view.
3535
FeatureViewMeta meta = 2;
36-
string project = 3;
3736
}
3837

3938
message FeatureViewSpec {
40-
// Name of the feature table. Must be unique. Not updated.
39+
// Name of the feature view. Must be unique. Not updated.
4140
string name = 1;
4241

42+
// Name of Feast project that this feature view belongs to.
43+
string project = 2;
44+
4345
// List names of entities to associate with the Features defined in this
4446
// Feature View. Not updatable.
4547
repeated string entities = 3;
4648

47-
// List of features specifications for each feature defined with this feature table.
49+
// List of features specifications for each feature defined with this feature view.
4850
repeated FeatureSpecV2 features = 4;
4951

5052
// User defined metadata
5153
map<string,string> tags = 5;
5254

53-
// Features in this feature table can only be retrieved from online serving
55+
// Features in this feature view can only be retrieved from online serving
5456
// younger than ttl. Ttl is measured as the duration of time between
5557
// the feature's event timestamp and when the feature is retrieved
5658
// Feature values outside ttl will be returned as unset values and indicated to end user
5759
google.protobuf.Duration ttl = 6;
5860

61+
// Batch/Offline DataSource where this view can retrieve offline feature data.
5962
DataSource input = 7;
6063

64+
// Whether these features should be served online or not
6165
bool online = 8;
6266
}
6367

sdk/python/feast/registry.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ def apply_entity(self, entity: Entity, project: str):
6464
"""
6565
entity.is_valid()
6666
entity_proto = entity.to_proto()
67-
entity_proto.project = project
67+
entity_proto.spec.project = project
6868

6969
def updater(registry_proto: RegistryProto):
7070
for idx, existing_entity_proto in enumerate(registry_proto.entities):
7171
if (
7272
existing_entity_proto.spec.name == entity_proto.spec.name
73-
and existing_entity_proto.project == project
73+
and existing_entity_proto.spec.project == project
7474
):
7575
del registry_proto.entities[idx]
7676
registry_proto.entities.append(entity_proto)
@@ -94,7 +94,7 @@ def list_entities(self, project: str) -> List[Entity]:
9494
registry_proto = self._registry_store.get_registry()
9595
entities = []
9696
for entity_proto in registry_proto.entities:
97-
if entity_proto.project == project:
97+
if entity_proto.spec.project == project:
9898
entities.append(Entity.from_proto(entity_proto))
9999
return entities
100100

@@ -112,7 +112,7 @@ def get_entity(self, name: str, project: str) -> Entity:
112112
"""
113113
registry_proto = self._registry_store.get_registry()
114114
for entity_proto in registry_proto.entities:
115-
if entity_proto.spec.name == name and entity_proto.project == project:
115+
if entity_proto.spec.name == name and entity_proto.spec.project == project:
116116
return Entity.from_proto(entity_proto)
117117
raise Exception(f"Entity {name} does not exist in project {project}")
118118

@@ -126,7 +126,7 @@ def apply_feature_table(self, feature_table: FeatureTable, project: str):
126126
"""
127127
feature_table.is_valid()
128128
feature_table_proto = feature_table.to_proto()
129-
feature_table_proto.project = project
129+
feature_table_proto.spec.project = project
130130

131131
def updater(registry_proto: RegistryProto):
132132
for idx, existing_feature_table_proto in enumerate(
@@ -135,7 +135,7 @@ def updater(registry_proto: RegistryProto):
135135
if (
136136
existing_feature_table_proto.spec.name
137137
== feature_table_proto.spec.name
138-
and existing_feature_table_proto.project == project
138+
and existing_feature_table_proto.spec.project == project
139139
):
140140
del registry_proto.feature_tables[idx]
141141
registry_proto.feature_tables.append(feature_table_proto)
@@ -156,7 +156,7 @@ def apply_feature_view(self, feature_view: FeatureView, project: str):
156156
"""
157157
feature_view.is_valid()
158158
feature_view_proto = feature_view.to_proto()
159-
feature_view_proto.project = project
159+
feature_view_proto.spec.project = project
160160

161161
def updater(registry_proto: RegistryProto):
162162
for idx, existing_feature_view_proto in enumerate(
@@ -165,7 +165,7 @@ def updater(registry_proto: RegistryProto):
165165
if (
166166
existing_feature_view_proto.spec.name
167167
== feature_view_proto.spec.name
168-
and existing_feature_view_proto.project == project
168+
and existing_feature_view_proto.spec.project == project
169169
):
170170
del registry_proto.feature_views[idx]
171171
registry_proto.feature_views.append(feature_view_proto)
@@ -188,7 +188,7 @@ def list_feature_tables(self, project: str) -> List[FeatureTable]:
188188
registry_proto = self._registry_store.get_registry()
189189
feature_tables = []
190190
for feature_table_proto in registry_proto.feature_tables:
191-
if feature_table_proto.project == project:
191+
if feature_table_proto.spec.project == project:
192192
feature_tables.append(FeatureTable.from_proto(feature_table_proto))
193193
return feature_tables
194194

@@ -205,7 +205,7 @@ def list_feature_views(self, project: str) -> List[FeatureView]:
205205
registry_proto = self._registry_store.get_registry()
206206
feature_views = []
207207
for feature_view_proto in registry_proto.feature_views:
208-
if feature_view_proto.project == project:
208+
if feature_view_proto.spec.project == project:
209209
feature_views.append(FeatureView.from_proto(feature_view_proto))
210210
return feature_views
211211

@@ -225,7 +225,7 @@ def get_feature_table(self, name: str, project: str) -> FeatureTable:
225225
for feature_table_proto in registry_proto.feature_tables:
226226
if (
227227
feature_table_proto.spec.name == name
228-
and feature_table_proto.project == project
228+
and feature_table_proto.spec.project == project
229229
):
230230
return FeatureTable.from_proto(feature_table_proto)
231231
raise Exception(f"Feature table {name} does not exist in project {project}")
@@ -246,7 +246,7 @@ def get_feature_view(self, name: str, project: str) -> FeatureView:
246246
for feature_view_proto in registry_proto.feature_views:
247247
if (
248248
feature_view_proto.spec.name == name
249-
and feature_view_proto.project == project
249+
and feature_view_proto.spec.project == project
250250
):
251251
return FeatureView.from_proto(feature_view_proto)
252252
raise Exception(f"Feature view {name} does not exist in project {project}")
@@ -266,7 +266,7 @@ def updater(registry_proto: RegistryProto):
266266
):
267267
if (
268268
existing_feature_table_proto.spec.name == name
269-
and existing_feature_table_proto.project == project
269+
and existing_feature_table_proto.spec.project == project
270270
):
271271
del registry_proto.feature_tables[idx]
272272
return registry_proto
@@ -290,7 +290,7 @@ def updater(registry_proto: RegistryProto):
290290
):
291291
if (
292292
existing_feature_view_proto.spec.name == name
293-
and existing_feature_view_proto.project == project
293+
and existing_feature_view_proto.spec.project == project
294294
):
295295
del registry_proto.feature_views[idx]
296296
return registry_proto

tmp/tmp/test.avro

289 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)