• 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/parser/create_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.
UNCOV
15
from typing import List, Tuple
×
16

UNCOV
17
from evadb.catalog.catalog_type import ColumnType, NdArrayType
×
UNCOV
18
from evadb.parser.select_statement import SelectStatement
×
UNCOV
19
from evadb.parser.statement import AbstractStatement
×
UNCOV
20
from evadb.parser.table_ref import TableInfo
×
UNCOV
21
from evadb.parser.types import StatementType
×
22

23

UNCOV
24
class ColConstraintInfo:
×
UNCOV
25
    def __init__(self, nullable=False, default_value=None, primary=False, unique=False):
×
UNCOV
26
        self.nullable = nullable
×
UNCOV
27
        self.default_value = default_value
×
UNCOV
28
        self.primary = primary
×
UNCOV
29
        self.unique = unique
×
30

UNCOV
31
    def __eq__(self, other):
×
UNCOV
32
        if not isinstance(other, ColConstraintInfo):
×
UNCOV
33
            return False
×
UNCOV
34
        return (
×
35
            self.nullable == other.nullable
36
            and self.default_value == other.default_value
37
            and self.primary == other.primary
38
            and self.unique == other.unique
39
        )
40

UNCOV
41
    def __hash__(self) -> int:
×
UNCOV
42
        return hash((self.nullable, self.default_value, self.primary, self.unique))
×
43

44

UNCOV
45
class ColumnDefinition:
×
UNCOV
46
    def __init__(
×
47
        self,
48
        col_name: str,
49
        col_type: ColumnType,
50
        col_array_type: NdArrayType,
51
        col_dim: Tuple[int],
52
        cci: ColConstraintInfo = ColConstraintInfo(),
53
    ):
UNCOV
54
        self._name = col_name
×
UNCOV
55
        self._type = col_type
×
UNCOV
56
        self._array_type = col_array_type
×
UNCOV
57
        self._dimension = col_dim or ()
×
UNCOV
58
        self._cci = cci
×
59

UNCOV
60
    @property
×
UNCOV
61
    def name(self):
×
UNCOV
62
        return self._name
×
63

UNCOV
64
    @name.setter
×
UNCOV
65
    def name(self, value):
×
UNCOV
66
        self._name = value
×
67

UNCOV
68
    @property
×
UNCOV
69
    def type(self):
×
UNCOV
70
        return self._type
×
71

UNCOV
72
    @property
×
UNCOV
73
    def array_type(self):
×
UNCOV
74
        return self._array_type
×
75

UNCOV
76
    @property
×
UNCOV
77
    def dimension(self):
×
UNCOV
78
        return self._dimension
×
79

UNCOV
80
    @property
×
UNCOV
81
    def cci(self):
×
UNCOV
82
        return self._cci
×
83

UNCOV
84
    def __str__(self):
×
UNCOV
85
        dimension_str = ""
×
UNCOV
86
        if self._dimension is not None:
×
UNCOV
87
            dimension_str += "["
×
UNCOV
88
            for dim in self._dimension:
×
UNCOV
89
                dimension_str += str(dim) + ", "
×
UNCOV
90
            dimension_str = dimension_str.rstrip(", ")
×
UNCOV
91
            dimension_str += "]"
×
92

UNCOV
93
        if self.array_type is None:
×
UNCOV
94
            return "{} {}".format(self._name, self._type)
×
95
        else:
UNCOV
96
            return "{} {} {} {}".format(
×
97
                self._name, self._type, self.array_type, dimension_str
98
            )
99

UNCOV
100
    def __eq__(self, other):
×
UNCOV
101
        if not isinstance(other, ColumnDefinition):
×
UNCOV
102
            return False
×
103

UNCOV
104
        return (
×
105
            self.name == other.name
106
            and self.type == other.type
107
            and self.array_type == other.array_type
108
            and self.dimension == other.dimension
109
            and self.cci == other.cci
110
        )
111

UNCOV
112
    def __hash__(self) -> int:
×
UNCOV
113
        return hash((self.name, self.type, self.array_type, self.dimension, self.cci))
×
114

115

UNCOV
116
class CreateTableStatement(AbstractStatement):
×
117
    """Create Table Statement constructed after parsing the input query
118

119
    Attributes:
120
        TableRef: table reference in the create table statement
121
        ColumnList: list of columns
122
    """
123

UNCOV
124
    def __init__(
×
125
        self,
126
        table_info: TableInfo,
127
        if_not_exists: bool,
128
        column_list: List[ColumnDefinition] = None,
129
        query: SelectStatement = None,
130
    ):
UNCOV
131
        super().__init__(StatementType.CREATE)
×
UNCOV
132
        self._table_info = table_info
×
UNCOV
133
        self._if_not_exists = if_not_exists
×
UNCOV
134
        self._column_list = column_list
×
UNCOV
135
        self._query = query
×
136

UNCOV
137
    def __str__(self) -> str:
×
UNCOV
138
        print_str = "CREATE TABLE {} ({}) \n".format(
×
139
            self._table_info, self._if_not_exists
140
        )
141

UNCOV
142
        if self._query is not None:
×
UNCOV
143
            print_str = "CREATE TABLE {} AS {}\n".format(self._table_info, self._query)
×
144

UNCOV
145
        for column in self.column_list:
×
UNCOV
146
            print_str += str(column) + "\n"
×
147

UNCOV
148
        return print_str
×
149

UNCOV
150
    @property
×
UNCOV
151
    def table_info(self):
×
UNCOV
152
        return self._table_info
×
153

UNCOV
154
    @property
×
UNCOV
155
    def if_not_exists(self):
×
UNCOV
156
        return self._if_not_exists
×
157

UNCOV
158
    @property
×
UNCOV
159
    def column_list(self):
×
UNCOV
160
        return self._column_list
×
161

UNCOV
162
    @property
×
UNCOV
163
    def query(self):
×
UNCOV
164
        return self._query
×
165

UNCOV
166
    @column_list.setter
×
UNCOV
167
    def column_list(self, value):
×
168
        self._column_list = value
×
169

UNCOV
170
    def __eq__(self, other):
×
UNCOV
171
        if not isinstance(other, CreateTableStatement):
×
UNCOV
172
            return False
×
UNCOV
173
        return (
×
174
            self.table_info == other.table_info
175
            and self.if_not_exists == other.if_not_exists
176
            and self.column_list == other.column_list
177
            and self.query == other.query
178
        )
179

UNCOV
180
    def __hash__(self) -> int:
×
UNCOV
181
        return hash(
×
182
            (
183
                super().__hash__(),
184
                self.table_info,
185
                self.if_not_exists,
186
                tuple(self.column_list or []),
187
                self.query,
188
            )
189
        )
190

191

UNCOV
192
class CreateDatabaseStatement(AbstractStatement):
×
UNCOV
193
    def __init__(
×
194
        self, database_name: str, if_not_exists: bool, engine: str, param_dict: dict
195
    ):
UNCOV
196
        super().__init__(StatementType.CREATE_DATABASE)
×
UNCOV
197
        self.database_name = database_name
×
UNCOV
198
        self.if_not_exists = if_not_exists
×
UNCOV
199
        self.engine = engine
×
UNCOV
200
        self.param_dict = param_dict
×
201

UNCOV
202
    def __eq__(self, other):
×
UNCOV
203
        if not isinstance(other, CreateDatabaseStatement):
×
UNCOV
204
            return False
×
UNCOV
205
        return (
×
206
            self.database_name == other.database_name
207
            and self.if_not_exists == other.if_not_exists
208
            and self.engine == other.engine
209
            and self.param_dict == other.param_dict
210
        )
211

UNCOV
212
    def __hash__(self) -> int:
×
UNCOV
213
        return hash(
×
214
            (
215
                super().__hash__(),
216
                self.database_name,
217
                self.if_not_exists,
218
                self.engine,
219
                hash(frozenset(self.param_dict.items())),
220
            )
221
        )
222

UNCOV
223
    def __str__(self) -> str:
×
UNCOV
224
        return (
×
225
            f"CREATE DATABASE {self.database_name} \n"
226
            f"WITH ENGINE '{self.engine}' , \n"
227
            f"PARAMETERS = {self.param_dict};"
228
        )
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