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

georgia-tech-db / eva / #898

24 Sep 2023 05:55PM UTC coverage: 69.124% (+32.5%) from 36.589%
#898

push

circleci

web-flow
feat: print error msg if creating built-in functions failed (#1204)

8449 of 12223 relevant lines covered (69.12%)

0.69 hits per line

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

81.25
/evadb/executor/create_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 evadb.database import EvaDBDatabase
1✔
16
from evadb.executor.abstract_executor import AbstractExecutor
17
from evadb.executor.executor_utils import (
1✔
18
    create_table_catalog_entry_for_native_table,
1✔
19
    handle_if_not_exists,
1✔
20
)
21
from evadb.plan_nodes.create_plan import CreatePlan
22
from evadb.storage.storage_engine import StorageEngine
23
from evadb.utils.logging_manager import logger
1✔
24

1✔
25

1✔
26
class CreateExecutor(AbstractExecutor):
1✔
27
    def __init__(self, db: EvaDBDatabase, node: CreatePlan):
28
        super().__init__(db, node)
29

1✔
30
    def exec(self, *args, **kwargs):
1✔
31
        # create a table in the ative database if set
1✔
32
        is_native_table = self.node.table_info.database_name is not None
33
        check_if_exists = False
1✔
34
        # if exists only supported for evadb tables
35
        if not is_native_table:
1✔
36
            check_if_exists = handle_if_not_exists(
1✔
37
                self.catalog(), self.node.table_info, self.node.if_not_exists
38
            )
1✔
39

1✔
40
        if not check_if_exists:
41
            create_table_done = False
42
            logger.debug(f"Creating table {self.node.table_info}")
43

1✔
44
            if not is_native_table:
1✔
45
                catalog_entry = self.catalog().create_and_insert_table_catalog_entry(
1✔
46
                    self.node.table_info, self.node.column_list
47
                )
1✔
48
            else:
1✔
49
                catalog_entry = create_table_catalog_entry_for_native_table(
50
                    self.node.table_info, self.node.column_list
51
                )
52
            storage_engine = StorageEngine.factory(self.db, catalog_entry)
×
53

54
            try:
55
                storage_engine.create(table=catalog_entry)
1✔
56
                create_table_done = True
57
                if self.children != []:
1✔
58
                    assert (
1✔
59
                        len(self.children) == 1
1✔
60
                    ), "Create table from query expects 1 child, finds {}".format(
1✔
61
                        len(self.children)
×
62
                    )
63
                    child = self.children[0]
64

65
                    # Populate the table
66
                    for batch in child.exec():
×
67
                        batch.drop_column_alias()
68
                        storage_engine.write(catalog_entry, batch)
69
            except Exception as e:
×
70
                # rollback if the create call fails
×
71
                if create_table_done:
×
72
                    storage_engine.drop(catalog_entry)
73
                raise 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