• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

georgia-tech-db / eva / #852

16 Nov 2023 08:34AM UTC coverage: 0.0%. Remained the same
#852

push

circleci

Andy Xu
Skip neuralforecast testcases

0 of 12596 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/evadb/executor/plan_executor.py
1
# coding=utf-8
2
# Copyright 2018-2023 EvaDB
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
from typing import Iterator, Union
×
16

17
from evadb.database import EvaDBDatabase
×
18
from evadb.executor.abstract_executor import AbstractExecutor
×
19
from evadb.executor.apply_and_merge_executor import ApplyAndMergeExecutor
×
20
from evadb.executor.create_database_executor import CreateDatabaseExecutor
×
21
from evadb.executor.create_executor import CreateExecutor
×
22
from evadb.executor.create_function_executor import CreateFunctionExecutor
×
23
from evadb.executor.create_index_executor import CreateIndexExecutor
×
24
from evadb.executor.create_job_executor import CreateJobExecutor
×
25
from evadb.executor.delete_executor import DeleteExecutor
×
26
from evadb.executor.drop_object_executor import DropObjectExecutor
×
27
from evadb.executor.exchange_executor import ExchangeExecutor
×
28
from evadb.executor.executor_utils import ExecutorError
×
29
from evadb.executor.explain_executor import ExplainExecutor
×
30
from evadb.executor.function_scan_executor import FunctionScanExecutor
×
31
from evadb.executor.groupby_executor import GroupByExecutor
×
32
from evadb.executor.hash_join_executor import HashJoinExecutor
×
33
from evadb.executor.insert_executor import InsertExecutor
×
34
from evadb.executor.join_build_executor import BuildJoinExecutor
×
35
from evadb.executor.limit_executor import LimitExecutor
×
36
from evadb.executor.load_executor import LoadDataExecutor
×
37
from evadb.executor.nested_loop_join_executor import NestedLoopJoinExecutor
×
38
from evadb.executor.orderby_executor import OrderByExecutor
×
39
from evadb.executor.pp_executor import PPExecutor
×
40
from evadb.executor.predicate_executor import PredicateExecutor
×
41
from evadb.executor.project_executor import ProjectExecutor
×
42
from evadb.executor.rename_executor import RenameExecutor
×
43
from evadb.executor.sample_executor import SampleExecutor
×
44
from evadb.executor.seq_scan_executor import SequentialScanExecutor
×
45
from evadb.executor.set_executor import SetExecutor
×
46
from evadb.executor.show_info_executor import ShowInfoExecutor
×
47
from evadb.executor.storage_executor import StorageExecutor
×
48
from evadb.executor.union_executor import UnionExecutor
×
49
from evadb.executor.use_executor import UseExecutor
×
50
from evadb.executor.vector_index_scan_executor import VectorIndexScanExecutor
×
51
from evadb.models.storage.batch import Batch
×
52
from evadb.parser.create_statement import CreateDatabaseStatement, CreateJobStatement
×
53
from evadb.parser.set_statement import SetStatement
×
54
from evadb.parser.statement import AbstractStatement
×
55
from evadb.parser.use_statement import UseStatement
×
56
from evadb.plan_nodes.abstract_plan import AbstractPlan
×
57
from evadb.plan_nodes.types import PlanOprType
×
58
from evadb.utils.logging_manager import logger
×
59

60

61
class PlanExecutor:
×
62
    """
63
    This is an interface between plan tree and execution tree.
64
    We traverse the plan tree and build execution tree from it
65

66
    Arguments:
67
        plan (AbstractPlan): Physical plan tree which needs to be executed
68
        evadb (EvaDBDatabase): database to execute the query on
69
    """
70

71
    def __init__(self, evadb: EvaDBDatabase, plan: AbstractPlan):
×
72
        self._db = evadb
×
73
        self._plan = plan
×
74

75
    def _build_execution_tree(
×
76
        self, plan: Union[AbstractPlan, AbstractStatement]
77
    ) -> AbstractExecutor:
78
        """build the execution tree from plan tree
79

80
        Arguments:
81
            plan {AbstractPlan} -- Input Plan tree
82

83
        Returns:
84
            AbstractExecutor -- Compiled Execution tree
85
        """
86
        root = None
×
87
        if plan is None:
×
88
            return root
×
89

90
        # First handle cases when the plan is actually a parser statement
91
        if isinstance(plan, CreateDatabaseStatement):
×
92
            return CreateDatabaseExecutor(db=self._db, node=plan)
×
93
        elif isinstance(plan, UseStatement):
×
94
            return UseExecutor(db=self._db, node=plan)
×
95
        elif isinstance(plan, SetStatement):
×
96
            return SetExecutor(db=self._db, node=plan)
×
97
        elif isinstance(plan, CreateJobStatement):
×
98
            return CreateJobExecutor(db=self._db, node=plan)
×
99

100
        # Get plan node type
101
        plan_opr_type = plan.opr_type
×
102

103
        if plan_opr_type == PlanOprType.SEQUENTIAL_SCAN:
×
104
            executor_node = SequentialScanExecutor(db=self._db, node=plan)
×
105
        elif plan_opr_type == PlanOprType.UNION:
×
106
            executor_node = UnionExecutor(db=self._db, node=plan)
×
107
        elif plan_opr_type == PlanOprType.STORAGE_PLAN:
×
108
            executor_node = StorageExecutor(db=self._db, node=plan)
×
109
        elif plan_opr_type == PlanOprType.PP_FILTER:
×
110
            executor_node = PPExecutor(db=self._db, node=plan)
×
111
        elif plan_opr_type == PlanOprType.CREATE:
×
112
            executor_node = CreateExecutor(db=self._db, node=plan)
×
113
        elif plan_opr_type == PlanOprType.RENAME:
×
114
            executor_node = RenameExecutor(db=self._db, node=plan)
×
115
        elif plan_opr_type == PlanOprType.DROP_OBJECT:
×
116
            executor_node = DropObjectExecutor(db=self._db, node=plan)
×
117
        elif plan_opr_type == PlanOprType.INSERT:
×
118
            executor_node = InsertExecutor(db=self._db, node=plan)
×
119
        elif plan_opr_type == PlanOprType.CREATE_FUNCTION:
×
120
            executor_node = CreateFunctionExecutor(db=self._db, node=plan)
×
121
        elif plan_opr_type == PlanOprType.LOAD_DATA:
×
122
            executor_node = LoadDataExecutor(db=self._db, node=plan)
×
123
        elif plan_opr_type == PlanOprType.GROUP_BY:
×
124
            executor_node = GroupByExecutor(db=self._db, node=plan)
×
125
        elif plan_opr_type == PlanOprType.ORDER_BY:
×
126
            executor_node = OrderByExecutor(db=self._db, node=plan)
×
127
        elif plan_opr_type == PlanOprType.LIMIT:
×
128
            executor_node = LimitExecutor(db=self._db, node=plan)
×
129
        elif plan_opr_type == PlanOprType.SAMPLE:
×
130
            executor_node = SampleExecutor(db=self._db, node=plan)
×
131
        elif plan_opr_type == PlanOprType.NESTED_LOOP_JOIN:
×
132
            executor_node = NestedLoopJoinExecutor(db=self._db, node=plan)
×
133
        elif plan_opr_type == PlanOprType.HASH_JOIN:
×
134
            executor_node = HashJoinExecutor(db=self._db, node=plan)
×
135
        elif plan_opr_type == PlanOprType.HASH_BUILD:
×
136
            executor_node = BuildJoinExecutor(db=self._db, node=plan)
×
137
        elif plan_opr_type == PlanOprType.FUNCTION_SCAN:
×
138
            executor_node = FunctionScanExecutor(db=self._db, node=plan)
×
139
        elif plan_opr_type == PlanOprType.EXCHANGE:
×
140
            executor_node = ExchangeExecutor(db=self._db, node=plan)
×
141
            inner_executor = self._build_execution_tree(plan.inner_plan)
×
142
            executor_node.build_inner_executor(inner_executor)
×
143
        elif plan_opr_type == PlanOprType.PROJECT:
×
144
            executor_node = ProjectExecutor(db=self._db, node=plan)
×
145
        elif plan_opr_type == PlanOprType.PREDICATE_FILTER:
×
146
            executor_node = PredicateExecutor(db=self._db, node=plan)
×
147
        elif plan_opr_type == PlanOprType.SHOW_INFO:
×
148
            executor_node = ShowInfoExecutor(db=self._db, node=plan)
×
149
        elif plan_opr_type == PlanOprType.EXPLAIN:
×
150
            executor_node = ExplainExecutor(db=self._db, node=plan)
×
151
        elif plan_opr_type == PlanOprType.CREATE_INDEX:
×
152
            executor_node = CreateIndexExecutor(db=self._db, node=plan)
×
153
        elif plan_opr_type == PlanOprType.APPLY_AND_MERGE:
×
154
            executor_node = ApplyAndMergeExecutor(db=self._db, node=plan)
×
155
        elif plan_opr_type == PlanOprType.VECTOR_INDEX_SCAN:
×
156
            executor_node = VectorIndexScanExecutor(db=self._db, node=plan)
×
157
        elif plan_opr_type == PlanOprType.DELETE:
×
158
            executor_node = DeleteExecutor(db=self._db, node=plan)
×
159

160
        # EXPLAIN does not need to build execution tree for its children
161
        if plan_opr_type != PlanOprType.EXPLAIN:
×
162
            # Build Executor Tree for children
163
            for children in plan.children:
×
164
                executor_node.append_child(self._build_execution_tree(children))
×
165

166
        return executor_node
×
167

168
    def execute_plan(
169
        self,
170
        do_not_raise_exceptions: bool = False,
171
        do_not_print_exceptions: bool = False,
172
    ) -> Iterator[Batch]:
173
        """execute the plan tree"""
174
        try:
×
175
            execution_tree = self._build_execution_tree(self._plan)
×
176
            output = execution_tree.exec()
×
177
            if output is not None:
×
178
                yield from output
×
179
        except Exception as e:
180
            if do_not_raise_exceptions is False:
181
                if do_not_print_exceptions is False:
182
                    logger.exception(str(e))
183
                raise ExecutorError(e)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc