|
1 | | -from datetime import timedelta |
| 1 | +from datetime import datetime, timedelta |
2 | 2 | from typing import Optional |
3 | 3 |
|
4 | 4 | import pyarrow as pa |
| 5 | +from data_source import DataSource |
5 | 6 |
|
6 | 7 | from feast.infra.compute_engines.dag.context import ExecutionContext |
7 | 8 | from feast.infra.compute_engines.local.arrow_table_value import ArrowTableValue |
|
15 | 16 |
|
16 | 17 |
|
17 | 18 | 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 | + ): |
19 | 26 | 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 |
22 | 30 |
|
23 | 31 | 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) |
26 | 52 |
|
27 | 53 |
|
28 | 54 | class LocalJoinNode(LocalNode): |
|
0 commit comments