Skip to content

Commit

Permalink
fix: Update data source timestamp inference error message to make sen…
Browse files Browse the repository at this point in the history
…se (#2636)

Signed-off-by: Achal Shah <achals@gmail.com>
  • Loading branch information
achals authored May 4, 2022
1 parent 737c488 commit 3eaf6b7
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions sdk/python/feast/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}`.
""",
)

Expand Down

0 comments on commit 3eaf6b7

Please sign in to comment.