Skip to content

Commit

Permalink
Enforce case-insensitively unique feature view names (#1835)
Browse files Browse the repository at this point in the history
* Enforce case-insensitively unique feature view names

Signed-off-by: Cody Lin <[email protected]>

* Update tests for case-insensitive uniqueness

Signed-off-by: Cody Lin <[email protected]>
  • Loading branch information
codyjlin authored Sep 7, 2021
1 parent cc61405 commit 0dc13f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
11 changes: 6 additions & 5 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,12 +982,13 @@ def _print_materialization_log(


def _validate_feature_views(feature_views: List[FeatureView]):
""" Verify feature views have unique names"""
name_to_fv_dict = {}
""" Verify feature views have case-insensitively unique names"""
fv_names = set()
for fv in feature_views:
if fv.name in name_to_fv_dict:
case_insensitive_fv_name = fv.name.lower()
if case_insensitive_fv_name in fv_names:
raise ValueError(
f"More than one feature view with name {fv.name} found. Please ensure that all feature view names are unique. It may be necessary to ignore certain files in your feature repository by using a .feastignore file."
f"More than one feature view with name {case_insensitive_fv_name} found. Please ensure that all feature view names are case-insensitively unique. It may be necessary to ignore certain files in your feature repository by using a .feastignore file."
)
else:
name_to_fv_dict[fv.name] = fv
fv_names.add(case_insensitive_fv_name)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def test_cli_apply_duplicated_featureview_names() -> None:

assert (
rc != 0
and b"Please ensure that all feature view names are unique" in output
and b"Please ensure that all feature view names are case-insensitively unique"
in output
)


Expand Down Expand Up @@ -76,5 +77,6 @@ def test_cli_apply_duplicated_featureview_names_multiple_py_files() -> None:

assert (
rc != 0
and b"Please ensure that all feature view names are unique" in output
and b"Please ensure that all feature view names are case-insensitively unique"
in output
)
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ def test_reapply_feature_view_success(test_feature_store, dataframe_source):
test_feature_store.teardown()


def test_apply_duplicated_featureview_names(feature_store_with_local_registry):
""" Test applying feature views with duplicated names"""
def test_apply_conflicting_featureview_names(feature_store_with_local_registry):
""" Test applying feature views with non-case-insensitively unique names"""

driver_stats = FeatureView(
name="driver_hourly_stats",
Expand All @@ -495,7 +495,7 @@ def test_apply_duplicated_featureview_names(feature_store_with_local_registry):
)

customer_stats = FeatureView(
name="driver_hourly_stats",
name="DRIVER_HOURLY_STATS",
entities=["id"],
ttl=timedelta(seconds=10),
online=False,
Expand All @@ -509,7 +509,8 @@ def test_apply_duplicated_featureview_names(feature_store_with_local_registry):
error = e
assert (
isinstance(error, ValueError)
and "Please ensure that all feature view names are unique" in error.args[0]
and "Please ensure that all feature view names are case-insensitively unique"
in error.args[0]
)

feature_store_with_local_registry.teardown()

0 comments on commit 0dc13f0

Please sign in to comment.