From 661c0535f34b042846562a3fb4cdab4ab4403459 Mon Sep 17 00:00:00 2001 From: Felix Wang Date: Thu, 21 Jul 2022 14:56:07 -0700 Subject: [PATCH] fix: Do not allow same column to be reused in data sources (#2965) * Do not allow same column to be reused in data sources Signed-off-by: Felix Wang * Fix bug Signed-off-by: Felix Wang --- sdk/python/feast/data_source.py | 7 +++++++ sdk/python/tests/unit/test_data_sources.py | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 6ab7934371..a1e44b3186 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -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 "" diff --git a/sdk/python/tests/unit/test_data_sources.py b/sdk/python/tests/unit/test_data_sources.py index 61891ccf1a..0b437e50b9 100644 --- a/sdk/python/tests/unit/test_data_sources.py +++ b/sdk/python/tests/unit/test_data_sources.py @@ -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", + )