Skip to content

Commit 0bbdbbc

Browse files
committed
update source read node
Signed-off-by: HaoXuAI <sduxuhao@gmail.com>
1 parent 4765d8f commit 0bbdbbc

File tree

1 file changed

+32
-6
lines changed
  • sdk/python/feast/infra/compute_engines/local

1 file changed

+32
-6
lines changed

sdk/python/feast/infra/compute_engines/local/nodes.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from datetime import timedelta
1+
from datetime import datetime, timedelta
22
from typing import Optional
33

44
import pyarrow as pa
5+
from data_source import DataSource
56

67
from feast.infra.compute_engines.dag.context import ExecutionContext
78
from feast.infra.compute_engines.local.arrow_table_value import ArrowTableValue
@@ -15,14 +16,39 @@
1516

1617

1718
class LocalSourceReadNode(LocalNode):
18-
def __init__(self, name: str, feature_view, task):
19+
def __init__(
20+
self,
21+
name: str,
22+
source: DataSource,
23+
start_time: Optional[datetime] = None,
24+
end_time: Optional[datetime] = None,
25+
):
1926
super().__init__(name)
20-
self.feature_view = feature_view
21-
self.task = task
27+
self.source = source
28+
self.start_time = start_time
29+
self.end_time = end_time
2230

2331
def execute(self, context: ExecutionContext) -> ArrowTableValue:
24-
# TODO : Implement the logic to read from offline store
25-
return ArrowTableValue(data=pa.Table.from_pandas(context.entity_df))
32+
offline_store = context.offline_store
33+
(
34+
join_key_columns,
35+
feature_name_columns,
36+
timestamp_field,
37+
created_timestamp_column,
38+
) = context.column_info
39+
40+
# 📥 Reuse Feast's robust query resolver
41+
retrieval_job = offline_store.pull_all_from_table_or_query(
42+
config=context.repo_config,
43+
data_source=self.source,
44+
join_key_columns=join_key_columns,
45+
feature_name_columns=feature_name_columns,
46+
timestamp_field=timestamp_field,
47+
start_date=self.start_time,
48+
end_date=self.end_time,
49+
)
50+
arrow_table = retrieval_job.to_arrow()
51+
return ArrowTableValue(data=arrow_table)
2652

2753

2854
class LocalJoinNode(LocalNode):

0 commit comments

Comments
 (0)