Skip to content

Commit

Permalink
fix: Update sql.py (feast-dev#3096)
Browse files Browse the repository at this point in the history
* Update sql.py

Fix a bug that `name = name or obj.name if hasattr(obj, "name") else None` has wrong order sequence.

Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com>

* add test

Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com>

* add test

Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com>

* fix lint

Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com>

Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com>
  • Loading branch information
hao-affirm authored and franciscojavierarceo committed Aug 17, 2022
1 parent dc85d5a commit 35d8c48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/python/feast/infra/registry/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def _apply_object(
):
self._maybe_init_project_metadata(project)

name = name or obj.name if hasattr(obj, "name") else None
name = name or (obj.name if hasattr(obj, "name") else None)
assert name, f"name needs to be provided for {obj}"

with self.engine.connect() as conn:
Expand Down
22 changes: 22 additions & 0 deletions sdk/python/tests/unit/test_sql_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,3 +551,25 @@ def test_apply_data_source(sql_registry):
assert registry_batch_source == batch_source

sql_registry.teardown()


@pytest.mark.skipif(
sys.platform == "darwin" and "GITHUB_REF" in os.environ,
reason="does not run on mac github actions",
)
@pytest.mark.parametrize(
"sql_registry",
[
lazy_fixture("mysql_registry"),
lazy_fixture("pg_registry"),
lazy_fixture("sqlite_registry"),
],
)
def test_update_infra(sql_registry):
# Create infra object
project = "project"
infra = sql_registry.get_infra(project=project)

# Should run update infra successfully
sql_registry.update_infra(infra, project)
sql_registry.teardown()

0 comments on commit 35d8c48

Please sign in to comment.