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

georgia-tech-db / eva / d1973b30-ed2d-490f-a4df-92b5108c2bd8

pending completion
d1973b30-ed2d-490f-a4df-92b5108c2bd8

Pull #551

circle-ci

jarulraj
run linter
Pull Request #551: feat: add support for aggregates

69 of 69 new or added lines in 6 files covered. (100.0%)

7906 of 8423 relevant lines covered (93.86%)

0.97 hits per line

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

90.24
/eva/parser/create_statement.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 List
1✔
16

17
from eva.catalog.catalog_type import ColumnType, NdArrayType
1✔
18
from eva.parser.statement import AbstractStatement
1✔
19
from eva.parser.table_ref import TableInfo
1✔
20
from eva.parser.types import StatementType
1✔
21

22

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

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

40
    def __hash__(self) -> int:
1✔
41
        return hash((self.nullable, self.default_value, self.primary, self.unique))
1✔
42

43

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

59
    @property
1✔
60
    def name(self):
1✔
61
        return self._name
1✔
62

63
    @property
1✔
64
    def type(self):
1✔
65
        return self._type
1✔
66

67
    @property
1✔
68
    def array_type(self):
1✔
69
        return self._array_type
1✔
70

71
    @property
1✔
72
    def dimension(self):
1✔
73
        return self._dimension
1✔
74

75
    @property
1✔
76
    def cci(self):
1✔
77
        return self._cci
1✔
78

79
    def __str__(self):
1✔
80
        dimension_str = ""
1✔
81
        if self._dimension is not None:
1✔
82
            dimension_str += "["
1✔
83
            for dim in self._dimension:
1✔
84
                dimension_str += str(dim) + ", "
1✔
85
            dimension_str = dimension_str.rstrip(", ")
1✔
86
            dimension_str += "]"
1✔
87

88
        if self.array_type is None:
1✔
89
            return "{} {}".format(self._name, self._type)
1✔
90
        else:
91
            return "{} {} {} {}".format(
1✔
92
                self._name, self._type, self.array_type, dimension_str
93
            )
94

95
    def __eq__(self, other):
1✔
96
        if not isinstance(other, ColumnDefinition):
1✔
97
            return False
×
98

99
        return (
1✔
100
            self.name == other.name
101
            and self.type == other.type
102
            and self.array_type == other.array_type
103
            and self.dimension == other.dimension
104
            and self.cci == other.cci
105
        )
106

107
    def __hash__(self) -> int:
1✔
108
        return hash(
1✔
109
            (self.name, self.type, self.array_type, tuple(self.dimension), self.cci)
110
        )
111

112

113
class CreateTableStatement(AbstractStatement):
1✔
114
    """Create Table Statement constructed after parsing the input query
115

116
    Attributes:
117
        TableRef: table reference in the create table statement
118
        ColumnList: list of columns
119
    """
120

121
    def __init__(
1✔
122
        self,
123
        table_info: TableInfo,
124
        if_not_exists: bool,
125
        column_list: List[ColumnDefinition] = None,
126
    ):
127
        super().__init__(StatementType.CREATE)
1✔
128
        self._table_info = table_info
1✔
129
        self._if_not_exists = if_not_exists
1✔
130
        self._column_list = column_list
1✔
131

132
    def __str__(self) -> str:
1✔
133
        print_str = "CREATE TABLE {} ({}) \n".format(
×
134
            self._table_info, self._if_not_exists
135
        )
136

137
        for column in self.column_list:
×
138
            print_str += str(column) + "\n"
×
139

140
        return print_str
×
141

142
    @property
1✔
143
    def table_info(self):
1✔
144
        return self._table_info
1✔
145

146
    @property
1✔
147
    def if_not_exists(self):
1✔
148
        return self._if_not_exists
1✔
149

150
    @property
1✔
151
    def column_list(self):
1✔
152
        return self._column_list
1✔
153

154
    def __eq__(self, other):
1✔
155
        if not isinstance(other, CreateTableStatement):
1✔
156
            return False
×
157
        return (
1✔
158
            self.table_info == other.table_info
159
            and self.if_not_exists == other.if_not_exists
160
            and self.column_list == other.column_list
161
        )
162

163
    def __hash__(self) -> int:
1✔
164
        return hash(
×
165
            (
166
                super().__hash__(),
167
                self.table_info,
168
                self.if_not_exists,
169
                tuple(self.column_list or []),
170
            )
171
        )
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