55
66import mmh3
77import pandas
8- import pyarrow
98from tqdm import tqdm
109
1110from feast import FeatureTable , utils
1211from feast .entity import Entity
1312from feast .errors import FeastProviderLoginError
1413from feast .feature_view import FeatureView
1514from feast .infra .key_encoding_utils import serialize_entity_key
16- from feast .infra .offline_stores .helpers import get_offline_store_from_sources
15+ from feast .infra .offline_stores .helpers import get_offline_store_from_config
1716from feast .infra .provider import (
1817 Provider ,
1918 RetrievalJob ,
2827
2928try :
3029 from google .auth .exceptions import DefaultCredentialsError
31- from google .cloud import bigquery , datastore
30+ from google .cloud import datastore
3231except ImportError as e :
3332 from feast .errors import FeastExtrasDependencyImportError
3433
@@ -40,11 +39,14 @@ class GcpProvider(Provider):
4039
4140 def __init__ (self , config : RepoConfig ):
4241 assert isinstance (config .online_store , DatastoreOnlineStoreConfig )
42+ assert config .offline_store is not None
4343 if config and config .online_store and config .online_store .project_id :
4444 self ._gcp_project_id = config .online_store .project_id
4545 else :
4646 self ._gcp_project_id = None
4747
48+ self .offline_store = get_offline_store_from_config (config .offline_store )
49+
4850 def _initialize_client (self ):
4951 try :
5052 if self ._gcp_project_id is not None :
@@ -168,8 +170,7 @@ def materialize_single_feature_view(
168170 start_date = utils .make_tzaware (start_date )
169171 end_date = utils .make_tzaware (end_date )
170172
171- offline_store = get_offline_store_from_sources ([feature_view .input ])
172- table = offline_store .pull_latest_from_table_or_query (
173+ table = self .offline_store .pull_latest_from_table_or_query (
173174 data_source = feature_view .input ,
174175 join_key_columns = join_key_columns ,
175176 feature_name_columns = feature_name_columns ,
@@ -193,25 +194,16 @@ def materialize_single_feature_view(
193194 feature_view .materialization_intervals .append ((start_date , end_date ))
194195 registry .apply_feature_view (feature_view , project )
195196
196- @staticmethod
197- def _pull_query (query : str ) -> pyarrow .Table :
198- client = bigquery .Client ()
199- query_job = client .query (query )
200- return query_job .to_arrow ()
201-
202- @staticmethod
203197 def get_historical_features (
198+ self ,
204199 config : RepoConfig ,
205200 feature_views : List [FeatureView ],
206201 feature_refs : List [str ],
207202 entity_df : Union [pandas .DataFrame , str ],
208203 registry : Registry ,
209204 project : str ,
210205 ) -> RetrievalJob :
211- offline_store = get_offline_store_from_sources (
212- [feature_view .input for feature_view in feature_views ]
213- )
214- job = offline_store .get_historical_features (
206+ job = self .offline_store .get_historical_features (
215207 config = config ,
216208 feature_views = feature_views ,
217209 feature_refs = feature_refs ,
0 commit comments