Skip to content

Commit 04dea73

Browse files
authored
fix: Added Redshift and Spark typecheck to data_source event_timestamp_col inference (#2389)
* added Redshift typecheck to data_source event_timestamp_col inference Signed-off-by: Shai Bruhis <shaibruhis@gmail.com> * address comments Signed-off-by: Shai Bruhis <shaibruhis@gmail.com> * moved non file data sources into their own test Signed-off-by: Shai Bruhis <shaibruhis@gmail.com> * addressed comments Signed-off-by: Shai Bruhis <shaibruhis@gmail.com> * fixed texts Signed-off-by: Shai Bruhis <shaibruhis@gmail.com> * remove previously defined event_timestamp_column from data_source to allow for inference Signed-off-by: Shai Bruhis <shaibruhis@gmail.com> * made a deepcopy of data_sources to not affect other tests Signed-off-by: Shai Bruhis <shaibruhis@gmail.com> * linter Signed-off-by: Shai Bruhis <shaibruhis@gmail.com>
1 parent e17028d commit 04dea73

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

sdk/python/feast/inference.py

+2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ def update_data_sources_with_inferred_event_timestamp_col(
111111
assert (
112112
isinstance(data_source, FileSource)
113113
or isinstance(data_source, BigQuerySource)
114+
or isinstance(data_source, RedshiftSource)
114115
or isinstance(data_source, SnowflakeSource)
116+
or "SparkSource" == data_source.__class__.__name__
115117
)
116118

117119
# loop through table columns to find singular match

sdk/python/tests/integration/feature_repos/repo_configuration.py

+3
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ class UniversalDataSources:
203203
global_ds: DataSource
204204
field_mapping: DataSource
205205

206+
def values(self):
207+
return dataclasses.asdict(self).values()
208+
206209

207210
def construct_universal_data_sources(
208211
datasets: UniversalDatasets, data_source_creator: DataSourceCreator

sdk/python/tests/integration/registration/test_inference.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from copy import deepcopy
2+
13
import pandas as pd
24
import pytest
35

@@ -111,7 +113,7 @@ def test_infer_datasource_names_dwh():
111113

112114

113115
@pytest.mark.integration
114-
def test_update_data_sources_with_inferred_event_timestamp_col(simple_dataset_1):
116+
def test_update_file_data_source_with_inferred_event_timestamp_col(simple_dataset_1):
115117
df_with_two_viable_timestamp_cols = simple_dataset_1.copy(deep=True)
116118
df_with_two_viable_timestamp_cols["ts_2"] = simple_dataset_1["ts_1"]
117119

@@ -138,6 +140,28 @@ def test_update_data_sources_with_inferred_event_timestamp_col(simple_dataset_1)
138140
)
139141

140142

143+
@pytest.mark.integration
144+
@pytest.mark.universal
145+
def test_update_data_sources_with_inferred_event_timestamp_col(universal_data_sources):
146+
(_, _, data_sources) = universal_data_sources
147+
data_sources_copy = deepcopy(data_sources)
148+
149+
# remove defined event_timestamp_column to allow for inference
150+
for data_source in data_sources_copy.values():
151+
data_source.event_timestamp_column = None
152+
153+
update_data_sources_with_inferred_event_timestamp_col(
154+
data_sources_copy.values(), RepoConfig(provider="local", project="test"),
155+
)
156+
actual_event_timestamp_cols = [
157+
source.event_timestamp_column for source in data_sources_copy.values()
158+
]
159+
160+
assert actual_event_timestamp_cols == ["event_timestamp"] * len(
161+
data_sources_copy.values()
162+
)
163+
164+
141165
def test_on_demand_features_type_inference():
142166
# Create Feature Views
143167
date_request = RequestDataSource(

0 commit comments

Comments
 (0)