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

georgia-tech-db / eva / #850

08 Nov 2023 08:36PM UTC coverage: 0.0% (-77.0%) from 76.982%
#850

push

circleci

americast
fix metrics logic

0 of 1 new or added line in 1 file covered. (0.0%)

9789 existing lines in 252 files now uncovered.

0 of 12428 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/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.
UNCOV
15
import contextlib
×
16

UNCOV
17
import pandas as pd
×
18

UNCOV
19
from evadb.database import EvaDBDatabase
×
UNCOV
20
from evadb.executor.abstract_executor import AbstractExecutor
×
UNCOV
21
from evadb.executor.executor_utils import (
×
22
    create_table_catalog_entry_for_native_table,
23
    handle_if_not_exists,
24
)
UNCOV
25
from evadb.models.storage.batch import Batch
×
UNCOV
26
from evadb.plan_nodes.create_plan import CreatePlan
×
UNCOV
27
from evadb.storage.storage_engine import StorageEngine
×
UNCOV
28
from evadb.utils.errors import CatalogError
×
UNCOV
29
from evadb.utils.logging_manager import logger
×
30

31

UNCOV
32
class CreateExecutor(AbstractExecutor):
×
UNCOV
33
    def __init__(self, db: EvaDBDatabase, node: CreatePlan):
×
UNCOV
34
        super().__init__(db, node)
×
35

UNCOV
36
    def exec(self, *args, **kwargs):
×
37
        # create a table in the active database if set
UNCOV
38
        is_native_table = self.node.table_info.database_name is not None
×
39

UNCOV
40
        check_if_exists = handle_if_not_exists(
×
41
            self.catalog(), self.node.table_info, self.node.if_not_exists
42
        )
UNCOV
43
        name = self.node.table_info.table_name
×
UNCOV
44
        if check_if_exists:
×
45
            yield Batch(pd.DataFrame([f"Table {name} already exists"]))
×
46
            return
×
47

UNCOV
48
        create_table_done = False
×
UNCOV
49
        logger.debug(f"Creating table {self.node.table_info}")
×
50

UNCOV
51
        if not is_native_table:
×
UNCOV
52
            catalog_entry = self.catalog().create_and_insert_table_catalog_entry(
×
53
                self.node.table_info, self.node.column_list
54
            )
55
        else:
56
            catalog_entry = create_table_catalog_entry_for_native_table(
×
57
                self.node.table_info, self.node.column_list
58
            )
UNCOV
59
        storage_engine = StorageEngine.factory(self.db, catalog_entry)
×
60

UNCOV
61
        try:
×
UNCOV
62
            storage_engine.create(table=catalog_entry)
×
UNCOV
63
            create_table_done = True
×
64

UNCOV
65
            msg = f"The table {name} has been successfully created"
×
UNCOV
66
            if self.children != []:
×
67
                assert (
×
68
                    len(self.children) == 1
69
                ), "Create table from query expects 1 child, finds {}".format(
70
                    len(self.children)
71
                )
72
                child = self.children[0]
×
73

74
                rows = 0
×
75
                # Populate the table
76
                for batch in child.exec():
×
77
                    batch.drop_column_alias()
×
78
                    storage_engine.write(catalog_entry, batch)
×
79
                    rows += len(batch)
×
80

81
                msg = (
×
82
                    f"The table {name} has been successfully created with {rows} rows."
83
                )
84

UNCOV
85
            yield Batch(pd.DataFrame([msg]))
×
86
        except Exception as e:
87
            # rollback if the create call fails
88
            with contextlib.suppress(CatalogError):
89
                if create_table_done:
90
                    storage_engine.drop(catalog_entry)
91
            # rollback catalog entry, suppress any errors raised by catalog
92
            with contextlib.suppress(CatalogError):
93
                self.catalog().delete_table_catalog_entry(catalog_entry)
94
            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