Skip to content

Commit

Permalink
fix: Do not allow same column to be reused in data sources (#2965)
Browse files Browse the repository at this point in the history
* Do not allow same column to be reused in data sources

Signed-off-by: Felix Wang <wangfelix98@gmail.com>

* Fix bug

Signed-off-by: Felix Wang <wangfelix98@gmail.com>
  • Loading branch information
felixwang9817 committed Jul 21, 2022
1 parent 5e45228 commit 661c053
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sdk/python/feast/data_source.py
Expand Up @@ -273,6 +273,13 @@ def __init__(
),
DeprecationWarning,
)
if (
self.timestamp_field
and self.timestamp_field == self.created_timestamp_column
):
raise ValueError(
"Please do not use the same column for 'timestamp_field' and 'created_timestamp_column'."
)
self.description = description or ""
self.tags = tags or {}
self.owner = owner or ""
Expand Down
10 changes: 10 additions & 0 deletions sdk/python/tests/unit/test_data_sources.py
Expand Up @@ -261,3 +261,13 @@ def test_proto_conversion():
assert DataSource.from_proto(kinesis_source.to_proto()) == kinesis_source
assert DataSource.from_proto(push_source.to_proto()) == push_source
assert DataSource.from_proto(request_source.to_proto()) == request_source


def test_column_conflict():
with pytest.raises(ValueError):
_ = FileSource(
name="test_source",
path="test_path",
timestamp_field="event_timestamp",
created_timestamp_column="event_timestamp",
)

0 comments on commit 661c053

Please sign in to comment.