Skip to content

Commit debef39

Browse files
committed
fix: Fix copy method for StreamFeatureView
Signed-off-by: fbad <fabio.badali@gmail.com>
1 parent 4e450ad commit debef39

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

sdk/python/feast/stream_feature_view.py

+4-2
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

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
from datetime import timedelta
23

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

0 commit comments

Comments
 (0)