Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3eaf6b7

Browse files
authored
fix: Update data source timestamp inference error message to make sense (#2636)
Signed-off-by: Achal Shah <[email protected]>
1 parent 737c488 commit 3eaf6b7

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

sdk/python/feast/inference.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,30 @@ def update_data_sources_with_inferred_event_timestamp_col(
5555
)
5656

5757
# loop through table columns to find singular match
58-
timestamp_field, matched_flag = None, False
58+
timestamp_fields = []
5959
for (
6060
col_name,
6161
col_datatype,
6262
) in data_source.get_table_column_names_and_types(config):
6363
if re.match(ts_column_type_regex_pattern, col_datatype):
64-
if matched_flag:
65-
raise RegistryInferenceFailure(
66-
"DataSource",
67-
f"""
68-
{ERROR_MSG_PREFIX} due to multiple possible columns satisfying
69-
the criteria. {ts_column_type_regex_pattern} {col_name}
70-
""",
71-
)
72-
matched_flag = True
73-
timestamp_field = col_name
74-
if matched_flag:
75-
assert timestamp_field
76-
data_source.timestamp_field = timestamp_field
64+
timestamp_fields.append(col_name)
65+
66+
if len(timestamp_fields) > 1:
67+
raise RegistryInferenceFailure(
68+
"DataSource",
69+
f"""{ERROR_MSG_PREFIX}; found multiple possible columns of timestamp type.
70+
Data source type: {data_source.__class__.__name__},
71+
Timestamp regex: `{ts_column_type_regex_pattern}`, columns: {timestamp_fields}""",
72+
)
73+
elif len(timestamp_fields) == 1:
74+
data_source.timestamp_field = timestamp_fields[0]
7775
else:
7876
raise RegistryInferenceFailure(
7977
"DataSource",
8078
f"""
81-
{ERROR_MSG_PREFIX} due to an absence of columns that satisfy the criteria.
79+
{ERROR_MSG_PREFIX}; Found no columns of timestamp type.
80+
Data source type: {data_source.__class__.__name__},
81+
Timestamp regex: `{ts_column_type_regex_pattern}`.
8282
""",
8383
)
8484

0 commit comments

Comments
 (0)