Skip to content

Commit

Permalink
feat: function catalog service to fetch function entries by type
Browse files Browse the repository at this point in the history
  • Loading branch information
aayushacharya committed Jan 25, 2024
1 parent e5a9190 commit 8ad7d9f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions evadb/catalog/catalog_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,20 @@ def get_function_catalog_entry_by_name(self, name: str) -> FunctionCatalogEntry:
"""
return self._function_service.get_entry_by_name(name)

def get_function_catalog_entries_by_type(
self, type: str
) -> List[FunctionCatalogEntry]:
"""
Get function information based on type.
Arguments:
type (str): type of the function
Returns:
List of FunctionCatalogEntry object
"""
return self._function_service.get_entries_by_type(type)

def delete_function_catalog_entry_by_name(self, function_name: str) -> bool:
return self._function_service.delete_entry_by_name(function_name)

Expand Down
18 changes: 18 additions & 0 deletions evadb/catalog/services/function_catalog_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ def get_entry_by_name(self, name: str) -> FunctionCatalogEntry:
return function_obj.as_dataclass()
return None

def get_entries_by_type(self, function_type: str) -> List[FunctionCatalogEntry]:
"""returns the function entries that matches the type provided.
Empty list if no such entry found.
Arguments:
type (str): name to be searched
"""

entries = (
self.session.execute(
select(self.model).filter(self.model._type == function_type)
)
.scalars()
.all()
)

return [entry.as_dataclass() for entry in entries]

def get_entry_by_id(self, id: int, return_alchemy=False) -> FunctionCatalogEntry:
"""return the function entry that matches the id provided.
None if no such entry found.
Expand Down

0 comments on commit 8ad7d9f

Please sign in to comment.