Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update data source timestamp inference error message to make sense #2636

Merged
merged 1 commit into from
May 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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