From fd896fb877ccfd22f95efe6ad7921dcdbc7640fa Mon Sep 17 00:00:00 2001 From: Felix Wang Date: Thu, 21 Jul 2022 12:38:21 -0700 Subject: [PATCH 1/2] Do not allow same column to be reused in data sources Signed-off-by: Felix Wang --- sdk/python/feast/data_source.py | 4 ++++ sdk/python/tests/unit/test_data_sources.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 6ab7934371..132acdac48 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -273,6 +273,10 @@ def __init__( ), DeprecationWarning, ) + if 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", + ) From e02e46146d2b3296a0c450d83e1fe236690df66e Mon Sep 17 00:00:00 2001 From: Felix Wang Date: Thu, 21 Jul 2022 13:54:31 -0700 Subject: [PATCH 2/2] Fix bug Signed-off-by: Felix Wang --- sdk/python/feast/data_source.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk/python/feast/data_source.py b/sdk/python/feast/data_source.py index 132acdac48..a1e44b3186 100644 --- a/sdk/python/feast/data_source.py +++ b/sdk/python/feast/data_source.py @@ -273,7 +273,10 @@ def __init__( ), DeprecationWarning, ) - if self.timestamp_field == self.created_timestamp_column: + 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'." )