feast.infra.offline_stores.contrib.postgres_offline_store package
Subpackages
- feast.infra.offline_stores.contrib.postgres_offline_store.tests package
- Submodules
- feast.infra.offline_stores.contrib.postgres_offline_store.tests.data_source module
PostgreSQLDataSourceCreator
PostgreSQLDataSourceCreator.create_data_source()
PostgreSQLDataSourceCreator.create_offline_store_config()
PostgreSQLDataSourceCreator.create_online_store()
PostgreSQLDataSourceCreator.create_saved_dataset_destination()
PostgreSQLDataSourceCreator.get_prefixed_table_name()
PostgreSQLDataSourceCreator.teardown()
postgres_container()
- Module contents
Submodules
feast.infra.offline_stores.contrib.postgres_offline_store.postgres module
- class feast.infra.offline_stores.contrib.postgres_offline_store.postgres.PostgreSQLOfflineStore[source]
Bases:
OfflineStore
- static get_historical_features(config: RepoConfig, feature_views: List[FeatureView], feature_refs: List[str], entity_df: DataFrame | str, registry: Registry, project: str, full_feature_names: bool = False) RetrievalJob [source]
Retrieves the point-in-time correct historical feature values for the specified entity rows.
- Parameters:
config – The config for the current feature store.
feature_views – A list containing all feature views that are referenced in the entity rows.
feature_refs – The features to be retrieved.
entity_df – A collection of rows containing all entity columns on which features need to be joined, as well as the timestamp column used for point-in-time joins. Either a pandas dataframe can be provided or a SQL query.
registry – The registry for the current feature store.
project – Feast project to which the feature views belong.
full_feature_names – If True, feature names will be prefixed with the corresponding feature view name, changing them from the format “feature” to “feature_view__feature” (e.g. “daily_transactions” changes to “customer_fv__daily_transactions”).
- Returns:
A RetrievalJob that can be executed to get the features.
- static pull_all_from_table_or_query(config: RepoConfig, data_source: DataSource, join_key_columns: List[str], feature_name_columns: List[str], timestamp_field: str, start_date: datetime, end_date: datetime) RetrievalJob [source]
Extracts all the entity rows (i.e. the combination of join key columns, feature columns, and timestamp columns) from the specified data source that lie within the specified time range.
All of the column names should refer to columns that exist in the data source. In particular, any mapping of column names must have already happened.
- Parameters:
config – The config for the current feature store.
data_source – The data source from which the entity rows will be extracted.
join_key_columns – The columns of the join keys.
feature_name_columns – The columns of the features.
timestamp_field – The timestamp column.
start_date – The start of the time range.
end_date – The end of the time range.
- Returns:
A RetrievalJob that can be executed to get the entity rows.
- static pull_latest_from_table_or_query(config: RepoConfig, data_source: DataSource, join_key_columns: List[str], feature_name_columns: List[str], timestamp_field: str, created_timestamp_column: str | None, start_date: datetime, end_date: datetime) RetrievalJob [source]
Extracts the latest entity rows (i.e. the combination of join key columns, feature columns, and timestamp columns) from the specified data source that lie within the specified time range.
All of the column names should refer to columns that exist in the data source. In particular, any mapping of column names must have already happened.
- Parameters:
config – The config for the current feature store.
data_source – The data source from which the entity rows will be extracted.
join_key_columns – The columns of the join keys.
feature_name_columns – The columns of the features.
timestamp_field – The timestamp column, used to determine which rows are the most recent.
created_timestamp_column – The column indicating when the row was created, used to break ties.
start_date – The start of the time range.
end_date – The end of the time range.
- Returns:
A RetrievalJob that can be executed to get the entity rows.
- class feast.infra.offline_stores.contrib.postgres_offline_store.postgres.PostgreSQLOfflineStoreConfig(*, host: StrictStr, port: int = 5432, database: StrictStr, db_schema: StrictStr = 'public', user: StrictStr, password: StrictStr, sslmode: StrictStr | None = None, sslkey_path: StrictStr | None = None, sslcert_path: StrictStr | None = None, sslrootcert_path: StrictStr | None = None, type: typing_extensions.Literal[postgres] = 'postgres')[source]
Bases:
PostgreSQLConfig
- type: typing_extensions.Literal[postgres]
- class feast.infra.offline_stores.contrib.postgres_offline_store.postgres.PostgreSQLRetrievalJob(query: str | Callable[[], AbstractContextManager[str]], config: RepoConfig, full_feature_names: bool, on_demand_feature_views: List[OnDemandFeatureView] | None = None, metadata: RetrievalMetadata | None = None)[source]
Bases:
RetrievalJob
- property full_feature_names: bool
Returns True if full feature names should be applied to the results of the query.
- property metadata: RetrievalMetadata | None
Returns metadata about the retrieval job.
- property on_demand_feature_views: List[OnDemandFeatureView]
Returns a list containing all the on demand feature views to be handled.
- persist(storage: SavedDatasetStorage, allow_overwrite: bool | None = False, timeout: int | None = None)[source]
Synchronously executes the underlying query and persists the result in the same offline store at the specified destination.
- Parameters:
storage – The saved dataset storage object specifying where the result should be persisted.
allow_overwrite – If True, a pre-existing location (e.g. table or file) can be overwritten. Currently not all individual offline store implementations make use of this parameter.
- feast.infra.offline_stores.contrib.postgres_offline_store.postgres.build_point_in_time_query(feature_view_query_contexts: List[dict], left_table_query_string: str, entity_df_event_timestamp_col: str, entity_df_columns: KeysView[str], query_template: str, full_feature_names: bool = False) str [source]
Build point-in-time query between each feature view table and the entity dataframe for PostgreSQL
feast.infra.offline_stores.contrib.postgres_offline_store.postgres_source module
- class feast.infra.offline_stores.contrib.postgres_offline_store.postgres_source.PostgreSQLOptions(name: str | None, query: str | None, table: str | None)[source]
Bases:
object
- class feast.infra.offline_stores.contrib.postgres_offline_store.postgres_source.PostgreSQLSource(name: str | None = None, query: str | None = None, table: str | None = None, timestamp_field: str | None = '', created_timestamp_column: str | None = '', field_mapping: Dict[str, str] | None = None, description: str | None = '', tags: Dict[str, str] | None = None, owner: str | None = '')[source]
Bases:
DataSource
- static from_proto(data_source: DataSource)[source]
Converts data source config in protobuf spec to a DataSource class object.
- Parameters:
data_source – A protobuf representation of a DataSource.
- Returns:
A DataSource class object.
- Raises:
ValueError – The type of DataSource could not be identified.
- get_table_column_names_and_types(config: RepoConfig) Iterable[Tuple[str, str]] [source]
Returns the list of column names and raw column types.
- Parameters:
config – Configuration object used to configure a feature store.
- get_table_query_string() str [source]
Returns a string that can directly be used to reference this table in SQL.
- static source_datatype_to_feast_value_type() Callable[[str], ValueType] [source]
Returns the callable method that returns Feast type given the raw column type.
- validate(config: RepoConfig)[source]
Validates the underlying data source.
- Parameters:
config – Configuration object used to configure a feature store.
- class feast.infra.offline_stores.contrib.postgres_offline_store.postgres_source.SavedDatasetPostgreSQLStorage(table_ref: str)[source]
Bases:
SavedDatasetStorage
- static from_proto(storage_proto: SavedDatasetStorage) SavedDatasetStorage [source]
- postgres_options: PostgreSQLOptions
- to_data_source() DataSource [source]