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

georgia-tech-db / eva / #840

18 Oct 2023 09:51PM UTC coverage: 68.616% (-9.8%) from 78.391%
#840

push

circle-ci

jiashenC
[BUMP]: v0.3.9+dev

2 of 2 new or added lines in 1 file covered. (100.0%)

8634 of 12583 relevant lines covered (68.62%)

0.69 hits per line

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

58.97
/evadb/parser/insert_statement.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 typing import List
1✔
16

17
from evadb.expression.abstract_expression import AbstractExpression
1✔
18
from evadb.parser.statement import AbstractStatement
1✔
19
from evadb.parser.table_ref import TableRef
1✔
20
from evadb.parser.types import StatementType
1✔
21

22

23
class InsertTableStatement(AbstractStatement):
1✔
24
    """
25
    Insert Table Statement constructed after parsing the input query
26

27
    Attributes
28
    ----------
29
    TableRef:
30
        table reference in the insert table statement
31
    ColumnList:
32
        list of columns
33
    ValueList:
34
        list of values to fill
35
    """
36

37
    def __init__(
1✔
38
        self,
39
        table_ref: TableRef,
40
        column_list: List[AbstractExpression] = None,
41
        value_list: List[AbstractExpression] = None,
42
    ):
43
        super().__init__(StatementType.INSERT)
1✔
44
        self._table_ref = table_ref
1✔
45
        self._column_list = column_list
1✔
46
        self._value_list = value_list
1✔
47

48
    def __str__(self) -> str:
1✔
49
        column_list_str = ""
×
50
        if self._column_list is not None:
×
51
            for expr in self._column_list:
×
52
                column_list_str += str(expr) + ", "
×
53
            column_list_str = column_list_str.rstrip(", ")
×
54

55
        value_list_str = ""
×
56
        if self._value_list is not None:
×
57
            for expr in self._value_list:
×
58
                value_list_str += str(expr) + ", "
×
59
            value_list_str = value_list_str.rstrip(", ")
×
60

61
        print_str = "INSERT INTO {}({}) VALUES ({}) ".format(
×
62
            self._table_ref, column_list_str, value_list_str
63
        )
64
        return print_str
×
65

66
    @property
1✔
67
    def table_ref(self) -> TableRef:
1✔
68
        return self._table_ref
1✔
69

70
    @property
1✔
71
    def column_list(self) -> List[AbstractExpression]:
1✔
72
        return self._column_list
1✔
73

74
    @property
1✔
75
    def value_list(self) -> List[AbstractExpression]:
1✔
76
        return self._value_list
1✔
77

78
    def __eq__(self, other):
1✔
79
        if not isinstance(other, InsertTableStatement):
×
80
            return False
×
81
        return (
×
82
            self.table_ref == other.table_ref
83
            and self.column_list == other.column_list
84
            and self.value_list == other.value_list
85
        )
86

87
    def __hash__(self) -> int:
1✔
88
        return hash(
×
89
            (
90
                super().__hash__(),
91
                self.table_ref,
92
                tuple(self.column_list),
93
                tuple(self.value_list),
94
            )
95
        )
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