File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments