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

georgia-tech-db / eva / #754

04 Sep 2023 09:54PM UTC coverage: 74.807% (-5.5%) from 80.336%
#754

push

circle-ci

jiashenC
update case

8727 of 11666 relevant lines covered (74.81%)

0.75 hits per line

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

44.0
/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
×
31
        table_catalog_entry = None
×
32

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

40
        # Implemented only for STRUCTURED_DATA
41
        assert (
×
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]
×
46
        tuple_to_insert = tuple(values_to_insert)
×
47
        columns_to_insert = [col_node.name for col_node in self.node.column_list]
×
48

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

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

56
        yield Batch(
×
57
            pd.DataFrame([f"Number of rows loaded: {str(len(values_to_insert))}"])
58
        )
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