Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Feast Spark Offline Store #2349

Merged
merged 58 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2366e85
State of feast
kevjumba Feb 25, 2022
20e82ea
Clean up changes
kevjumba Feb 26, 2022
55e7915
Fix random incorrect changes
kevjumba Feb 26, 2022
43794f7
Fix lint
kevjumba Feb 26, 2022
343ed00
Fix build errors
kevjumba Feb 26, 2022
55c458d
Fix lint
kevjumba Feb 26, 2022
b8ace43
Add spark offline store components to test against current integratio…
kevjumba Mar 1, 2022
d13119f
Fix lint
kevjumba Mar 1, 2022
4b56f55
Rename to pass checks
kevjumba Mar 1, 2022
6e278c4
Fix issues
kevjumba Mar 1, 2022
4bc67d8
Fix type checking issues
kevjumba Mar 1, 2022
c934edc
Fix lint
kevjumba Mar 1, 2022
e01d023
Clean up print statements for first review
kevjumba Mar 1, 2022
01ac14a
Fix lint
kevjumba Mar 1, 2022
26c8a01
Fix flake 8 lint tests
kevjumba Mar 1, 2022
6f8ce3c
Add warnings for alpha version release
kevjumba Mar 2, 2022
551eea1
Format
kevjumba Mar 2, 2022
1e7c2b4
Address review
kevjumba Mar 2, 2022
8e3e9a4
Address review
kevjumba Mar 2, 2022
cc1651e
Fix lint
kevjumba Mar 2, 2022
acf1c28
Add file store functionality
kevjumba Mar 2, 2022
65b113a
lint
kevjumba Mar 2, 2022
7adb8d2
Add example feature repo
kevjumba Mar 2, 2022
648f935
Update data source creator
kevjumba Mar 2, 2022
7b84ac1
Make cli work for feast init with spark
kevjumba Mar 2, 2022
b066a6f
Update the docs
kevjumba Mar 2, 2022
e0099ae
Clean up code
kevjumba Mar 2, 2022
86e74c0
Clean up more code
kevjumba Mar 2, 2022
6fe5b9e
Uncomment repo configs
kevjumba Mar 2, 2022
92c4f87
Fix setup.py
kevjumba Mar 2, 2022
18a2892
Update dependencies
kevjumba Mar 2, 2022
c644388
Fix ci dependencies
kevjumba Mar 3, 2022
9333130
Screwed up rebase
kevjumba Mar 3, 2022
6272f05
Screwed up rebase
kevjumba Mar 3, 2022
cf6bae1
Screwed up rebase
kevjumba Mar 3, 2022
0569b6d
Realign with master
kevjumba Mar 3, 2022
b02e51e
Fix accidental changes
kevjumba Mar 3, 2022
a161fad
Make type map change cleaner
kevjumba Mar 3, 2022
f7c618a
Address review comments
kevjumba Mar 3, 2022
c81fe31
Fix tests accidentally broken
kevjumba Mar 3, 2022
d790a1c
Add comments
kevjumba Mar 3, 2022
1408b8f
Reformat
kevjumba Mar 3, 2022
bf071b3
Fix logger
kevjumba Mar 3, 2022
62a92ac
Remove unused imports
kevjumba Mar 3, 2022
3ec6d22
Fix imports
kevjumba Mar 3, 2022
62ff185
Fix CI dependencies
adchia Mar 3, 2022
0dbc4e7
Prefix destinations with project name
kevjumba Mar 3, 2022
40cb4f8
Update comment
kevjumba Mar 3, 2022
4f5359a
Fix 3.8
kevjumba Mar 3, 2022
513d5bc
temporary fix
kevjumba Mar 3, 2022
8805884
rollback
kevjumba Mar 4, 2022
3ac3b71
update
kevjumba Mar 4, 2022
cfbaef5
Update ci?
kevjumba Mar 4, 2022
6abea5f
Move third party to contrib
kevjumba Mar 4, 2022
05aaeb8
Fix imports
kevjumba Mar 4, 2022
29a60d7
Remove third_party refactor
kevjumba Mar 4, 2022
b43417e
Revert ci requirements and update comment in type map
kevjumba Mar 4, 2022
1acc088
Revert 3.8-requirements
kevjumba Mar 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/reference/data-sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Please see [Data Source](../../getting-started/concepts/feature-view.md#data-sou
{% page-ref page="bigquery.md" %}

{% page-ref page="redshift.md" %}

{% page-ref page="spark.md" %}
45 changes: 45 additions & 0 deletions docs/reference/data-sources/spark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Spark

## Description

**NOTE**: Spark data source api is currently in alpha development and the API is not completely stable. The API may change or update in the future.

The spark data source API allows for the retrieval of historical feature values from file/database sources for building training datasets as well as materializing features into an online store.

* Either a table name, a SQL query, or a file path can be provided.

## Examples

Using a table reference from SparkSession(for example, either in memory or a Hive Metastore)

```python
from feast import SparkSource

my_spark_source = SparkSource(
table="FEATURE_TABLE",
)
```

Using a query

```python
from feast import SparkSource

my_spark_source = SparkSource(
query="SELECT timestamp as ts, created, f1, f2 "
"FROM spark_table",
)
```

Using a file reference

```python
from feast import SparkSource

my_spark_source = SparkSource(
path=f"{CURRENT_DIR}/data/driver_hourly_stats",
file_format="parquet",
event_timestamp_column="event_timestamp",
created_timestamp_column="created",
)
```
2 changes: 2 additions & 0 deletions docs/reference/offline-stores/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Please see [Offline Store](../../getting-started/architecture-and-components/off
{% page-ref page="bigquery.md" %}

{% page-ref page="redshift.md" %}

{% page-ref page="spark.md" %}
38 changes: 38 additions & 0 deletions docs/reference/offline-stores/spark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Spark

## Description

The Spark offline store is an offline store currently in alpha development that provides support for reading [SparkSources](../data-sources/spark.md).

## Disclaimer

This Spark offline store still does not achieve full test coverage and continues to fail some integration tests when integrating with the feast universal test suite. Please do NOT assume complete stability of the API.

* Spark tables and views are allowed as sources that are loaded in from some Spark store(e.g in Hive or in memory).
* Entity dataframes can be provided as a SQL query or can be provided as a Pandas dataframe. Pandas dataframes will be converted to a Spark dataframe and processed as a temporary view.
* A `SparkRetrievalJob` is returned when calling `get_historical_features()`.
* This allows you to call
* `to_df` to retrieve the pandas dataframe.
* `to_arrow` to retrieve the dataframe as a pyarrow Table.
* `to_spark_df` to retrieve the dataframe the spark.

## Example

{% code title="feature_store.yaml" %}
```yaml
project: my_project
registry: data/registry.db
provider: local
offline_store:
type: spark
spark_conf:
spark.master: "local[*]"
spark.ui.enabled: "false"
spark.eventLog.enabled: "false"
spark.sql.catalogImplementation: "hive"
spark.sql.parser.quotedRegexColumnNames: "true"
spark.sql.session.timeZone: "UTC"
online_store:
path: data/online_store.db
```
{% endcode %}
4 changes: 4 additions & 0 deletions sdk/python/feast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from pkg_resources import DistributionNotFound, get_distribution

from feast.infra.offline_stores.bigquery_source import BigQuerySource
from feast.infra.offline_stores.contrib.spark_offline_store.spark_source import (
SparkSource,
)
from feast.infra.offline_stores.file_source import FileSource
from feast.infra.offline_stores.redshift_source import RedshiftSource
from feast.infra.offline_stores.snowflake_source import SnowflakeSource
Expand Down Expand Up @@ -47,4 +50,5 @@
"RedshiftSource",
"RequestFeatureView",
"SnowflakeSource",
"SparkSource",
]
4 changes: 3 additions & 1 deletion sdk/python/feast/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ def materialize_incremental_command(ctx: click.Context, end_ts: str, views: List
@click.option(
"--template",
"-t",
type=click.Choice(["local", "gcp", "aws", "snowflake"], case_sensitive=False),
type=click.Choice(
["local", "gcp", "aws", "snowflake", "spark"], case_sensitive=False
),
help="Specify a template for the created project",
default="local",
)
Expand Down
7 changes: 5 additions & 2 deletions sdk/python/feast/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
FileSource,
RedshiftSource,
SnowflakeSource,
SparkSource,
)
from feast.data_source import DataSource
from feast.errors import RegistryInferenceFailure
Expand Down Expand Up @@ -84,7 +85,9 @@ def update_data_sources_with_inferred_event_timestamp_col(
):
# prepare right match pattern for data source
ts_column_type_regex_pattern = ""
if isinstance(data_source, FileSource):
if isinstance(data_source, FileSource) or isinstance(
data_source, SparkSource
):
ts_column_type_regex_pattern = r"^timestamp"
elif isinstance(data_source, BigQuerySource):
ts_column_type_regex_pattern = "TIMESTAMP|DATETIME"
Expand All @@ -97,7 +100,7 @@ def update_data_sources_with_inferred_event_timestamp_col(
"DataSource",
"""
DataSource inferencing of event_timestamp_column is currently only supported
for FileSource and BigQuerySource.
for FileSource, SparkSource, BigQuerySource, RedshiftSource, and SnowflakeSource.
""",
)
# for informing the type checker
Expand Down
Loading