Skip to content

Commit 00a55e5

Browse files
committed
WIP pull query from BQ
Signed-off-by: Jacob Klegar <jacob@tecton.ai>
1 parent dc48008 commit 00a55e5

3 files changed

Lines changed: 8 additions & 11 deletions

File tree

sdk/python/feast/data_source.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def to_proto(self) -> DataSourceProto.BigQueryOptions:
172172

173173
bigquery_options_proto = DataSourceProto.BigQueryOptions(
174174
table_ref=self.table_ref,
175+
query=self.query,
175176
)
176177

177178
return bigquery_options_proto
@@ -461,13 +462,14 @@ def from_proto(data_source):
461462
created_timestamp_column=data_source.created_timestamp_column,
462463
date_partition_column=data_source.date_partition_column,
463464
)
464-
elif data_source.bigquery_options.table_ref:
465+
elif (data_source.bigquery_options.table_ref or data_source.bigquery_options.query):
465466
data_source_obj = BigQuerySource(
466467
field_mapping=data_source.field_mapping,
467468
table_ref=data_source.bigquery_options.table_ref,
468469
event_timestamp_column=data_source.event_timestamp_column,
469470
created_timestamp_column=data_source.created_timestamp_column,
470471
date_partition_column=data_source.date_partition_column,
472+
query=data_source.bigquery_options.query,
471473
)
472474
elif (
473475
data_source.kafka_options.bootstrap_servers

sdk/python/feast/feature_store.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ def materialize(
217217
raise NotImplementedError(
218218
"This function is not yet implemented for File data sources"
219219
)
220-
if not feature_view.input.table_ref:
221-
raise NotImplementedError(
222-
f"This function is only implemented for FeatureViews with a table_ref; {feature_view.name} does not have one."
223-
)
224220
(
225221
entity_names,
226222
feature_names,

sdk/python/feast/offline_store.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,10 @@ def pull_latest_from_table(
125125
end_date: datetime,
126126
) -> pyarrow.Table:
127127
assert isinstance(data_source, BigQuerySource)
128-
table_ref = data_source.table_ref
129-
if table_ref is None:
130-
raise ValueError(
131-
"This function can only be called on a FeatureView with a table_ref"
132-
)
128+
if data_source.table_ref:
129+
from_table = f"`{data_source.table_ref}`"
130+
else:
131+
from_table = f"({data_source.query})"
133132

134133
partition_by_entity_string = ", ".join(entity_names)
135134
if partition_by_entity_string != "":
@@ -145,7 +144,7 @@ def pull_latest_from_table(
145144
FROM (
146145
SELECT {field_string},
147146
ROW_NUMBER() OVER({partition_by_entity_string} ORDER BY {timestamp_desc_string}) AS _feast_row
148-
FROM `{table_ref}`
147+
FROM {from_table}
149148
WHERE {event_timestamp_column} BETWEEN TIMESTAMP('{start_date}') AND TIMESTAMP('{end_date}')
150149
)
151150
WHERE _feast_row = 1

0 commit comments

Comments
 (0)