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

georgia-tech-db / eva / d8e82e0e-8b3d-4d22-9a86-fe9f65c8b264

28 Oct 2023 10:50PM UTC coverage: 67.392% (-9.6%) from 76.956%
d8e82e0e-8b3d-4d22-9a86-fe9f65c8b264

push

circle-ci

xzdandy
Use table for side by side display

8763 of 13003 relevant lines covered (67.39%)

0.67 hits per line

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

84.06
/evadb/parser/create_index_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.catalog.catalog_type import VectorStoreType
1✔
18
from evadb.expression.abstract_expression import AbstractExpression
1✔
19
from evadb.expression.function_expression import FunctionExpression
1✔
20
from evadb.expression.tuple_value_expression import TupleValueExpression
1✔
21
from evadb.parser.create_statement import ColumnDefinition
1✔
22
from evadb.parser.statement import AbstractStatement
1✔
23
from evadb.parser.table_ref import TableRef
1✔
24
from evadb.parser.types import StatementType
1✔
25

26

27
class CreateIndexStatement(AbstractStatement):
1✔
28
    def __init__(
1✔
29
        self,
30
        name: str,
31
        if_not_exists: bool,
32
        table_ref: TableRef,
33
        col_list: List[ColumnDefinition],
34
        vector_store_type: VectorStoreType,
35
        project_expr_list: List[AbstractStatement],
36
    ):
37
        super().__init__(StatementType.CREATE_INDEX)
1✔
38
        self._name = name
1✔
39
        self._if_not_exists = if_not_exists
1✔
40
        self._table_ref = table_ref
1✔
41
        self._col_list = col_list
1✔
42
        self._vector_store_type = vector_store_type
1✔
43
        self._project_expr_list = project_expr_list
1✔
44

45
        # Definition of CREATE INDEX.
46
        self._index_def = self.__str__()
1✔
47

48
    def __str__(self) -> str:
1✔
49
        function_expr = None
1✔
50
        for project_expr in self._project_expr_list:
1✔
51
            if isinstance(project_expr, FunctionExpression):
1✔
52
                function_expr = project_expr
×
53

54
        print_str = "CREATE INDEX"
1✔
55
        if self._if_not_exists:
1✔
56
            print_str += " IF NOT EXISTS"
×
57
        print_str += f" {self._name}"
1✔
58
        print_str += " ON"
1✔
59
        print_str += f" {self._table_ref.table.table_name}"
1✔
60
        if function_expr is None:
1✔
61
            print_str += f" ({self.col_list[0].name})"
1✔
62
        else:
63

64
            def traverse_create_function_expression_str(expr):
×
65
                if isinstance(expr, TupleValueExpression):
×
66
                    return f"{self.col_list[0].name}"
×
67
                return f"{expr.name}({traverse_create_function_expression_str(expr.children[0])})"
×
68

69
            print_str += f" ({traverse_create_function_expression_str(function_expr)})"
×
70
        print_str += f" USING {self._vector_store_type};"
1✔
71
        return print_str
1✔
72

73
    @property
1✔
74
    def name(self):
1✔
75
        return self._name
1✔
76

77
    @property
1✔
78
    def if_not_exists(self):
1✔
79
        return self._if_not_exists
1✔
80

81
    @property
1✔
82
    def table_ref(self):
1✔
83
        return self._table_ref
1✔
84

85
    @property
1✔
86
    def col_list(self):
1✔
87
        return self._col_list
1✔
88

89
    @property
1✔
90
    def vector_store_type(self):
1✔
91
        return self._vector_store_type
1✔
92

93
    @property
1✔
94
    def project_expr_list(self):
1✔
95
        return self._project_expr_list
1✔
96

97
    @project_expr_list.setter
1✔
98
    def project_expr_list(self, project_expr_list: List[AbstractExpression]):
1✔
99
        self._project_expr_list = project_expr_list
1✔
100

101
    @property
1✔
102
    def index_def(self):
1✔
103
        return self._index_def
1✔
104

105
    def __eq__(self, other):
1✔
106
        if not isinstance(other, CreateIndexStatement):
×
107
            return False
×
108
        return (
×
109
            self._name == other.name
110
            and self._if_not_exists == other.if_not_exists
111
            and self._table_ref == other.table_ref
112
            and self.col_list == other.col_list
113
            and self._vector_store_type == other.vector_store_type
114
            and self._project_expr_list == other.project_expr_list
115
            and self._index_def == other.index_def
116
        )
117

118
    def __hash__(self) -> int:
1✔
119
        return hash(
×
120
            (
121
                super().__hash__(),
122
                self._name,
123
                self._if_not_exists,
124
                self._table_ref,
125
                tuple(self.col_list),
126
                self._vector_store_type,
127
                tuple(self._project_expr_list),
128
                self._index_def,
129
            )
130
        )
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