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

georgia-tech-db / eva / #832

12 Oct 2023 08:31AM UTC coverage: 0.0% (-68.5%) from 68.493%
#832

push

circle-ci

xzdandy
Minor

0 of 12331 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_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
×
16

17
from evadb.catalog.catalog_type import VectorStoreType
×
18
from evadb.expression.abstract_expression import AbstractExpression
×
19
from evadb.expression.function_expression import FunctionExpression
×
20
from evadb.expression.tuple_value_expression import TupleValueExpression
×
21
from evadb.parser.create_statement import ColumnDefinition
×
22
from evadb.parser.statement import AbstractStatement
×
23
from evadb.parser.table_ref import TableRef
×
24
from evadb.parser.types import StatementType
×
25

26

27
class CreateIndexStatement(AbstractStatement):
×
28
    def __init__(
×
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)
×
38
        self._name = name
×
39
        self._if_not_exists = if_not_exists
×
40
        self._table_ref = table_ref
×
41
        self._col_list = col_list
×
42
        self._vector_store_type = vector_store_type
×
43
        self._project_expr_list = project_expr_list
×
44

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

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

54
        print_str = "CREATE INDEX"
×
55
        if self._if_not_exists:
×
56
            print_str += " IF NOT EXISTS"
×
57
        print_str += f" {self._name}"
×
58
        print_str += " ON"
×
59
        print_str += f" {self._table_ref.table.table_name}"
×
60
        if function_expr is None:
×
61
            print_str += f" ({self.col_list[0].name})"
×
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};"
×
71
        return print_str
×
72

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

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

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

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

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

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

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

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

105
    def __eq__(self, other):
×
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:
×
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