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

georgia-tech-db / eva / #758

04 Sep 2023 08:37PM UTC coverage: 0.0% (-78.3%) from 78.333%
#758

push

circle-ci

hershd23
Increased underline length in at line 75 in text_summarization.rst
	modified:   docs/source/benchmarks/text_summarization.rst

0 of 11303 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.
15
from typing import List, Tuple
×
16

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

23

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

31
    def __eq__(self, other):
×
32
        if not isinstance(other, ColConstraintInfo):
×
33
            return False
×
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

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

44

45
class ColumnDefinition:
×
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
    ):
54
        self._name = col_name
×
55
        self._type = col_type
×
56
        self._array_type = col_array_type
×
57
        self._dimension = col_dim or ()
×
58
        self._cci = cci
×
59

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

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

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

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

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

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

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

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

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

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

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

115

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

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
    ):
131
        super().__init__(StatementType.CREATE)
×
132
        self._table_info = table_info
×
133
        self._if_not_exists = if_not_exists
×
134
        self._column_list = column_list
×
135
        self._query = query
×
136

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

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

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

148
        return print_str
×
149

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

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

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

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

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

170
    def __eq__(self, other):
×
171
        if not isinstance(other, CreateTableStatement):
×
172
            return False
×
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

180
    def __hash__(self) -> int:
×
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

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

202
    def __eq__(self, other):
×
203
        if not isinstance(other, CreateDatabaseStatement):
×
204
            return False
×
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

212
    def __hash__(self) -> int:
×
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

223
    def __str__(self) -> str:
×
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

© 2025 Coveralls, Inc