diff --git a/evadb/executor/plan_executor.py b/evadb/executor/plan_executor.py index 8ab6460540..a3b945b9f6 100644 --- a/evadb/executor/plan_executor.py +++ b/evadb/executor/plan_executor.py @@ -161,7 +161,7 @@ def _build_execution_tree( return executor_node - def execute_plan( + def __call__( self, do_not_raise_exceptions: bool = False, do_not_print_exceptions: bool = False, diff --git a/evadb/interfaces/relational/utils.py b/evadb/interfaces/relational/utils.py index 35ab056ddf..4fad207613 100644 --- a/evadb/interfaces/relational/utils.py +++ b/evadb/interfaces/relational/utils.py @@ -53,9 +53,10 @@ def sql_predicate_to_expresssion_tree(expr: str) -> AbstractExpression: def execute_statement(evadb: EvaDBDatabase, statement: AbstractStatement) -> Batch: StatementBinder(StatementBinderContext(evadb.catalog)).bind(statement) - l_plan = StatementToPlanConverter().visit(statement) - p_plan = PlanGenerator(evadb).build(l_plan) - output = PlanExecutor(evadb, p_plan).execute_plan() + logical_plan = StatementToPlanConverter().visit(statement) + physical_plan = PlanGenerator(evadb).build(logical_plan) + plan_executor = PlanExecutor(evadb, physical_plan) + output = plan_executor() if output: batch_list = list(output) return Batch.concat(batch_list, copy=False) diff --git a/evadb/server/command_handler.py b/evadb/server/command_handler.py index 44882b746c..2d618bfa3f 100644 --- a/evadb/server/command_handler.py +++ b/evadb/server/command_handler.py @@ -49,13 +49,12 @@ def execute_query( # executor. if not isinstance(stmt, SKIP_BINDER_AND_OPTIMIZER_STATEMENTS): StatementBinder(StatementBinderContext(evadb.catalog)).bind(stmt) - l_plan = StatementToPlanConverter().visit(stmt) - p_plan = plan_generator.build(l_plan) + logical_plan = StatementToPlanConverter().visit(stmt) + physical_plan = plan_generator.build(logical_plan) else: - p_plan = stmt - output = PlanExecutor(evadb, p_plan).execute_plan( - do_not_raise_exceptions, do_not_print_exceptions - ) + physical_plan = stmt + plan_executor = PlanExecutor(evadb, physical_plan) + output = plan_executor(do_not_raise_exceptions, do_not_print_exceptions) if report_time is True: query_compile_time.log_elapsed_time("Query Compile Time") diff --git a/test/executor/test_plan_executor.py b/test/executor/test_plan_executor.py index 50b36809aa..2f272d031a 100644 --- a/test/executor/test_plan_executor.py +++ b/test/executor/test_plan_executor.py @@ -132,7 +132,7 @@ def test_execute_plan_for_seq_scan_plan(self, mock_build): tree.exec.return_value = batch_list mock_build.return_value = tree - actual = list(PlanExecutor(MagicMock(), None).execute_plan()) + actual = list(PlanExecutor(MagicMock(), None)()) mock_build.assert_called_once_with(None) tree.exec.assert_called_once() @@ -150,7 +150,7 @@ def test_execute_plan_for_pp_scan_plan(self, mock_build): tree.exec.return_value = batch_list mock_build.return_value = tree - actual = list(PlanExecutor(MagicMock(), None).execute_plan()) + actual = list(PlanExecutor(MagicMock(), None)()) mock_build.assert_called_once_with(None) tree.exec.assert_called_once() @@ -161,7 +161,7 @@ def test_execute_plan_for_create_insert_load_upload_plans(self, mock_build): # CreateExecutor tree = MagicMock(node=CreatePlan(None, [], False)) mock_build.return_value = tree - actual = list(PlanExecutor(MagicMock(), None).execute_plan()) + actual = list(PlanExecutor(MagicMock(), None)()) tree.exec.assert_called_once() mock_build.assert_called_once_with(None) @@ -172,7 +172,7 @@ def test_execute_plan_for_create_insert_load_upload_plans(self, mock_build): tree = MagicMock(node=InsertPlan(0, [], [])) mock_build.return_value = tree - actual = list(PlanExecutor(MagicMock(), None).execute_plan()) + actual = list(PlanExecutor(MagicMock(), None)()) tree.exec.assert_called_once() mock_build.assert_called_once_with(None) @@ -183,7 +183,7 @@ def test_execute_plan_for_create_insert_load_upload_plans(self, mock_build): tree = MagicMock(node=CreateUDFPlan(None, False, [], [], None)) mock_build.return_value = tree - actual = list(PlanExecutor(MagicMock(), None).execute_plan()) + actual = list(PlanExecutor(MagicMock(), None)()) tree.exec.assert_called_once() mock_build.assert_called_once_with(None) @@ -194,7 +194,7 @@ def test_execute_plan_for_create_insert_load_upload_plans(self, mock_build): tree = MagicMock(node=LoadDataPlan(None, None, None, None, None)) mock_build.return_value = tree - actual = list(PlanExecutor(MagicMock(), None).execute_plan()) + actual = list(PlanExecutor(MagicMock(), None)()) tree.exec.assert_called_once() mock_build.assert_called_once_with(None) @@ -205,7 +205,7 @@ def test_execute_plan_for_rename_plans(self, mock_build): # RenameExecutor tree = MagicMock(node=RenamePlan(None, None)) mock_build.return_value = tree - actual = list(PlanExecutor(MagicMock(), None).execute_plan()) + actual = list(PlanExecutor(MagicMock(), None)()) tree.exec.assert_called_once() mock_build.assert_called_once_with(None) @@ -216,7 +216,7 @@ def test_execute_plan_for_drop_plans(self, mock_build): # DropExecutor tree = MagicMock(node=DropObjectPlan(None, None, None)) mock_build.return_value = tree - actual = list(PlanExecutor(MagicMock(), None).execute_plan()) + actual = list(PlanExecutor(MagicMock(), None)()) tree.exec.assert_called_once() mock_build.assert_called_once_with(None) @@ -243,7 +243,7 @@ def test_should_return_the_new_path_after_execution(self, mock_class): # Execute the plan executor = PlanExecutor(seq_scan) - actual = executor.execute_plan() + actual = executor() expected = batch_1[::2] + batch_2[::2] mock_class.assert_called_once()