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

georgia-tech-db / eva / d88c9094-1a92-4944-91ea-5e7e8275cb11

23 Nov 2023 10:19PM UTC coverage: 67.117% (+67.1%) from 0.0%
d88c9094-1a92-4944-91ea-5e7e8275cb11

push

circleci

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

342 of 692 new or added lines in 47 files covered. (49.42%)

12 existing lines in 4 files now uncovered.

9189 of 13691 relevant lines covered (67.12%)

0.67 hits per line

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

66.67
/evadb/executor/insert_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
import pandas as pd
1✔
16

17
from evadb.catalog.catalog_type import TableType
1✔
18
from evadb.database import EvaDBDatabase
1✔
19
from evadb.executor.abstract_executor import AbstractExecutor
1✔
20
from evadb.models.storage.batch import Batch
1✔
21
from evadb.plan_nodes.insert_plan import InsertPlan
1✔
22
from evadb.storage.storage_engine import StorageEngine
1✔
23

24

25
class InsertExecutor(AbstractExecutor):
1✔
26
    def __init__(self, db: EvaDBDatabase, node: InsertPlan):
1✔
27
        super().__init__(db, node)
1✔
28

29
    def exec(self, *args, **kwargs):
1✔
30
        storage_engine = None
1✔
31
        table_catalog_entry = None
1✔
32

33
        # Get catalog entry
34
        table_name = self.node.table_ref.table.table_name
1✔
35
        database_name = self.node.table_ref.table.database_name
1✔
36
        table_catalog_entry = self.catalog().get_table_catalog_entry(
1✔
37
            table_name, database_name
38
        )
39

40
        # Implemented only for STRUCTURED_DATA
41
        assert (
1✔
42
            table_catalog_entry.table_type == TableType.STRUCTURED_DATA
43
        ), "INSERT only implemented for structured data"
44

45
        values_to_insert = [val_node.value for val_node in self.node.value_list]
1✔
46
        tuple_to_insert = tuple(values_to_insert)
1✔
47
        columns_to_insert = [col_node.name for col_node in self.node.column_list]
1✔
48

49
        # Adding all values to Batch for insert
50
        dataframe = pd.DataFrame([tuple_to_insert], columns=columns_to_insert)
1✔
51
        batch = Batch(dataframe)
1✔
52

53
        storage_engine = StorageEngine.factory(self.db, table_catalog_entry)
1✔
54
        storage_engine.write(table_catalog_entry, batch)
1✔
55

56
        # Index update if there is an index built on the table.
57
        for index in self.db.catalog().get_all_index_catalog_entries():
1✔
58
            is_index_on_current_table = False
×
59
            for column in table_catalog_entry.columns:
×
60
                if column == index.feat_column:
×
61
                    is_index_on_current_table = True
×
NEW
62
                    break
×
63
            if is_index_on_current_table:
×
NEW
64
                create_index_query = index.index_def
×
NEW
65
                create_index_query_list = create_index_query.split(" ")
×
66
                if_not_exists = " ".join(create_index_query_list[2:5]).lower()
×
67
                if if_not_exists != "if not exists":
×
68
                    create_index_query = (
×
69
                        " ".join(create_index_query_list[:2])
70
                        + " IF NOT EXISTS "
71
                        + " ".join(create_index_query_list[2:])
72
                    )
73
                from evadb.server.command_handler import execute_query_fetch_all
×
74

75
                execute_query_fetch_all(self.db, create_index_query)
×
76

77
        yield Batch(
1✔
78
            pd.DataFrame([f"Number of rows loaded: {str(len(values_to_insert))}"])
79
        )
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

© 2025 Coveralls, Inc