Skip to content

Commit

Permalink
Added SHOW JOBS statement to list all jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
kompy99 committed Nov 25, 2023
1 parent 334c8b1 commit e62baa8
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions evadb/catalog/catalog_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ def update_job_catalog_entry(
self._job_catalog_service.update_next_scheduled_run(
job_name, next_scheduled_run, active
)

def get_all_job_catalog_entry_names(self):
return self._job_catalog_service.get_all_job_names()

"Job history catalog services"

Expand Down
13 changes: 13 additions & 0 deletions evadb/catalog/services/job_catalog_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,16 @@ def update_next_scheduled_run(
job._next_scheduled_run = next_scheduled_run
job._active = active
self.session.commit()

def get_all_job_names(self) -> list:
"""Get the list of names of all jobs
Arguments:
None
Returns:
Returns the list of names of all jobs
"""
entries = self.session.execute(
select(self.model._name)
).scalars().all()
return entries

2 changes: 1 addition & 1 deletion evadb/executor/create_job_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def exec(self, *args, **kwargs):
start_time = (
self._parse_datetime_str(self.node.start_time)
if self.node.start_time is not None
else datetime.datetime.now()
else datetime.now()
)
end_time = (
self._parse_datetime_str(self.node.end_time)
Expand Down
7 changes: 7 additions & 0 deletions evadb/executor/show_info_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def exec(self, *args, **kwargs):
or ShowType.TABLES
or ShowType.DATABASES
or ShowType.CONFIGS
or ShowType.JOBS
), f"Show command does not support type {self.node.show_type}"

if self.node.show_type is ShowType.FUNCTIONS:
Expand Down Expand Up @@ -68,5 +69,11 @@ def exec(self, *args, **kwargs):
raise Exception(
"No configuration found with key {}".format(self.node.show_val)
)

elif self.node.show_type is ShowType.JOBS:
job_names = self.catalog().get_all_job_catalog_entry_names()
for name in job_names:
show_entries.append(name)
show_entries = {"Job Names": show_entries}

yield Batch(pd.DataFrame(show_entries))
3 changes: 2 additions & 1 deletion evadb/parser/evadb.lark
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe_statement: DESCRIBE table_name

help_statement: HELP STRING_LITERAL

show_statement: SHOW (FUNCTIONS | TABLES | uid | DATABASES)
show_statement: SHOW (FUNCTIONS | TABLES | uid | DATABASES | JOBS)

explain_statement: EXPLAIN explainable_statement

Expand Down Expand Up @@ -387,6 +387,7 @@ INDEX: "INDEX"i
INSERT: "INSERT"i
IS: "IS"i
JOB: "JOB"i
JOBS: "JOBS"i
JOIN: "JOIN"i
KEY: "KEY"i
LATERAL: "LATERAL"i
Expand Down
2 changes: 2 additions & 0 deletions evadb/parser/lark_visitor/_show_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ def show_statement(self, tree):
return ShowStatement(show_type=ShowType.TABLES)
elif isinstance(token, str) and str.upper(token) == "DATABASES":
return ShowStatement(show_type=ShowType.DATABASES)
elif isinstance(token, str) and str.upper(token) == "JOBS":
return ShowStatement(show_type=ShowType.JOBS)
elif token is not None:
return ShowStatement(show_type=ShowType.CONFIGS, show_val=self.visit(token))
2 changes: 2 additions & 0 deletions evadb/parser/show_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def __str__(self):
show_str = self.show_val
elif self.show_type == ShowType.DATABASES:
show_str = "DATABASES"
elif self.show_type == ShowType.JOBS:
show_str = "JOBS"
return f"SHOW {show_str}"

def __eq__(self, other: object) -> bool:
Expand Down
1 change: 1 addition & 0 deletions evadb/parser/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ShowType(EvaDBEnum):
TABLES # noqa: F821
CONFIGS # noqa: F821
DATABASES # noqa: F821
JOBS # noqa: F821


class FunctionType(EvaDBEnum):
Expand Down

0 comments on commit e62baa8

Please sign in to comment.