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

georgia-tech-db / eva / 79000c30-425a-4d3d-b9ba-c40b73e104fd

18 Sep 2023 07:30PM UTC coverage: 79.745% (-0.4%) from 80.158%
79000c30-425a-4d3d-b9ba-c40b73e104fd

push

circle-ci

web-flow
Merge branch 'georgia-tech-db:staging' into vector_pinecone

164 of 164 new or added lines in 17 files covered. (100.0%)

9563 of 11992 relevant lines covered (79.74%)

1.44 hits per line

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

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

25

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

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

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

44
            if not is_native_table:
2✔
45
                catalog_entry = self.catalog().create_and_insert_table_catalog_entry(
2✔
46
                    self.node.table_info, self.node.column_list
47
                )
48
            else:
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)
2✔
53

54
            try:
2✔
55
                storage_engine.create(table=catalog_entry)
2✔
56
                create_table_done = True
2✔
57
                if self.children != []:
2✔
58
                    assert (
×
59
                        len(self.children) == 1
60
                    ), "Create table from query expects 1 child, finds {}".format(
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