From 23f9f97932a67c5a1770b14eb3ba7f0f0f8e9f4b Mon Sep 17 00:00:00 2001 From: Achal Shah Date: Wed, 4 May 2022 11:50:58 -0700 Subject: [PATCH] fix: Update data source timestamp inference error message to make sense Signed-off-by: Achal Shah --- sdk/python/feast/inference.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sdk/python/feast/inference.py b/sdk/python/feast/inference.py index d3f2d94532..9ca6e9a988 100644 --- a/sdk/python/feast/inference.py +++ b/sdk/python/feast/inference.py @@ -55,30 +55,30 @@ def update_data_sources_with_inferred_event_timestamp_col( ) # loop through table columns to find singular match - timestamp_field, matched_flag = None, False + timestamp_fields = [] for ( col_name, col_datatype, ) in data_source.get_table_column_names_and_types(config): if re.match(ts_column_type_regex_pattern, col_datatype): - if matched_flag: - raise RegistryInferenceFailure( - "DataSource", - f""" - {ERROR_MSG_PREFIX} due to multiple possible columns satisfying - the criteria. {ts_column_type_regex_pattern} {col_name} - """, - ) - matched_flag = True - timestamp_field = col_name - if matched_flag: - assert timestamp_field - data_source.timestamp_field = timestamp_field + timestamp_fields.append(col_name) + + if len(timestamp_fields) > 1: + raise RegistryInferenceFailure( + "DataSource", + f"""{ERROR_MSG_PREFIX}; found multiple possible columns of timestamp type. + Data source type: {data_source.__class__.__name__}, + Timestamp regex: `{ts_column_type_regex_pattern}`, columns: {timestamp_fields}""", + ) + elif len(timestamp_fields) == 1: + data_source.timestamp_field = timestamp_fields[0] else: raise RegistryInferenceFailure( "DataSource", f""" - {ERROR_MSG_PREFIX} due to an absence of columns that satisfy the criteria. + {ERROR_MSG_PREFIX}; Found no columns of timestamp type. + Data source type: {data_source.__class__.__name__}, + Timestamp regex: `{ts_column_type_regex_pattern}`. """, )