Skip to content

Commit cf06704

Browse files
authored
fix: Fix copy method for StreamFeatureView (#3951)
Signed-off-by: fbad <fabio.badali@gmail.com>
1 parent 9e58bd4 commit cf06704

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

sdk/python/feast/stream_feature_view.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ def __copy__(self):
284284
fv = StreamFeatureView(
285285
name=self.name,
286286
schema=self.schema,
287-
entities=self.entities,
288287
ttl=self.ttl,
289288
tags=self.tags,
290289
online=self.online,
@@ -293,9 +292,12 @@ def __copy__(self):
293292
aggregations=self.aggregations,
294293
mode=self.mode,
295294
timestamp_field=self.timestamp_field,
296-
source=self.source,
295+
source=self.stream_source if self.stream_source else self.batch_source,
297296
udf=self.udf,
298297
)
298+
fv.entities = self.entities
299+
fv.features = copy.copy(self.features)
300+
fv.entity_columns = copy.copy(self.entity_columns)
299301
fv.projection = copy.copy(self.projection)
300302
return fv
301303

sdk/python/tests/unit/test_feature_views.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
from datetime import timedelta
23

34
import pytest
@@ -300,3 +301,22 @@ def test_stream_feature_view_proto_type():
300301
aggregations=[],
301302
)
302303
assert sfv.proto_class is StreamFeatureViewProto
304+
305+
306+
def test_stream_feature_view_copy():
307+
stream_source = KafkaSource(
308+
name="kafka",
309+
timestamp_field="event_timestamp",
310+
kafka_bootstrap_servers="",
311+
message_format=AvroFormat(""),
312+
topic="topic",
313+
batch_source=FileSource(path="some path"),
314+
)
315+
sfv = StreamFeatureView(
316+
name="test stream featureview proto class",
317+
entities=[],
318+
ttl=timedelta(days=30),
319+
source=stream_source,
320+
aggregations=[],
321+
)
322+
assert sfv == copy.copy(sfv)

0 commit comments

Comments
 (0)