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

georgia-tech-db / eva / 17d27eeb-d1e1-4c3b-a59c-b789a33e18ef

pending completion
17d27eeb-d1e1-4c3b-a59c-b789a33e18ef

Pull #587

circle-ci

jarulraj
checkpoint
Pull Request #587: feat: Delete and Insert operators for structured data

227 of 227 new or added lines in 22 files covered. (100.0%)

8477 of 9086 relevant lines covered (93.3%)

0.93 hits per line

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

81.63
/eva/executor/delete_executor.py
1
# coding=utf-8
2
# Copyright 2018-2022 EVA
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 typing import Generator, Iterator
1✔
16

17
import pandas as pd
1✔
18

19
from eva.catalog.catalog_manager import CatalogManager
1✔
20
from eva.catalog.catalog_type import TableType
1✔
21
from eva.executor.abstract_executor import AbstractExecutor
1✔
22
from eva.executor.executor_utils import ExecutorError, apply_predicate
1✔
23
from eva.models.storage.batch import Batch
1✔
24
from eva.plan_nodes.project_plan import ProjectPlan
1✔
25
from eva.storage.storage_engine import StorageEngine
1✔
26
from eva.utils.logging_manager import logger
1✔
27

28

29
class DeleteExecutor(AbstractExecutor):
1✔
30
    """ """
31

32
    def __init__(self, node: ProjectPlan):
1✔
33
        super().__init__(node)
1✔
34
        self.predicate = node.where_clause
1✔
35
        self.catalog = CatalogManager()
1✔
36

37
    def validate(self):
1✔
38
        pass
×
39

40
    def exec(self, **kwargs) -> Iterator[Batch]:
1✔
41
        try:
1✔
42
            table_catalog = self.node.table_ref.table.table_obj
1✔
43
            storage_engine = StorageEngine.factory(table_catalog)
1✔
44

45
            del_batch = Batch()
1✔
46

47
            if table_catalog.table_type == TableType.VIDEO_DATA:
1✔
48
                raise NotImplementedError("DELETE only implemented for structured data")
×
49
            elif table_catalog.table_type == TableType.IMAGE_DATA:
1✔
50
                raise NotImplementedError("DELETE only implemented for structured data")
×
51
            elif table_catalog.table_type == TableType.STRUCTURED_DATA:
1✔
52
                del_batch = storage_engine.read(table_catalog)
1✔
53
                del_batch = list(del_batch)[0]
1✔
54

55
            # Added because of inconsistency in col_alias in Structured data Batch project function
56
            original_column_names = list(del_batch.frames.columns)
1✔
57
            column_names = [
1✔
58
                f"{table_catalog.name.lower()}.{name}"
59
                for name in original_column_names
60
                if not name == "_row_id"
61
            ]
62
            column_names.insert(0, "_row_id")
1✔
63
            del_batch.frames.columns = column_names
1✔
64
            del_batch = apply_predicate(del_batch, self.predicate)
1✔
65

66
            # All the batches that need to be deleted
67

68
            if table_catalog.table_type == TableType.VIDEO_DATA:
1✔
69
                storage_engine.delete(table_catalog, del_batch)
×
70
            elif table_catalog.table_type == TableType.IMAGE_DATA:
1✔
71
                storage_engine.delete(table_catalog, del_batch)
×
72
            elif table_catalog.table_type == TableType.STRUCTURED_DATA:
1✔
73
                del_batch.frames.columns = original_column_names
1✔
74
                table_needed = del_batch.frames[
1✔
75
                    [f"{self.predicate.children[0].col_name}"]
76
                ]
77
                for num in range(len(del_batch)):
1✔
78
                    storage_engine.delete(table_catalog, table_needed.iloc[num])
1✔
79
            yield Batch(pd.DataFrame(["Deleted row"]))
1✔
80

81
        except Exception as e:
×
82
            logger.error(e)
×
83
            raise ExecutorError(e)
×
84

85
    def __call__(self, **kwargs) -> Generator[Batch, None, None]:
1✔
86
        yield from self.exec(**kwargs)
×
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