• 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_function_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 pathlib import Path
×
UNCOV
16
from typing import List, Tuple
×
17

UNCOV
18
from evadb.parser.create_statement import ColumnDefinition
×
UNCOV
19
from evadb.parser.select_statement import SelectStatement
×
UNCOV
20
from evadb.parser.statement import AbstractStatement
×
UNCOV
21
from evadb.parser.types import StatementType
×
22

23

UNCOV
24
class CreateFunctionStatement(AbstractStatement):
×
25
    """CreateFunctionStatement constructed after parsing the input query
26

27
    Attributes:
28
        name: str
29
            function_name provided by the user required
30
        if_not_exists: bool
31
            if true should throw an error if function with same name exists
32
            else will replace the existing
33
        inputs: List[ColumnDefinition]
34
            function inputs, represented similar to a table column definition
35
        outputs: List[ColumnDefinition]
36
            function outputs, represented similar to a table column definition
37
        impl_file_path: str
38
            file path which holds the implementation of the function.
39
            This file should be placed in the function directory and
40
            the path provided should be relative to the function dir.
41
        query: SelectStatement
42
            data source for the model train or fine tune.
43
        function_type: str
44
            function type. it can be object detection, classification etc.
45
        metadata: List[Tuple[str, str]]
46
            metadata, list of key value pairs used for storing metadata of functions, mostly used for advanced function types
47
    """
48

UNCOV
49
    def __init__(
×
50
        self,
51
        name: str,
52
        or_replace: bool,
53
        if_not_exists: bool,
54
        impl_path: str,
55
        inputs: List[ColumnDefinition] = [],
56
        outputs: List[ColumnDefinition] = [],
57
        function_type: str = None,
58
        query: SelectStatement = None,
59
        metadata: List[Tuple[str, str]] = None,
60
    ):
UNCOV
61
        super().__init__(StatementType.CREATE_FUNCTION)
×
UNCOV
62
        self._name = name
×
UNCOV
63
        self._or_replace = or_replace
×
UNCOV
64
        self._if_not_exists = if_not_exists
×
UNCOV
65
        self._inputs = inputs
×
UNCOV
66
        self._outputs = outputs
×
UNCOV
67
        self._impl_path = Path(impl_path) if impl_path else None
×
UNCOV
68
        self._function_type = function_type
×
UNCOV
69
        self._query = query
×
UNCOV
70
        self._metadata = metadata
×
71

UNCOV
72
    def __str__(self) -> str:
×
UNCOV
73
        s = "CREATE"
×
74

UNCOV
75
        if self._or_replace:
×
76
            s += " OR REPLACE"
×
77

UNCOV
78
        s += " " + "FUNCTION"
×
79

UNCOV
80
        if self._if_not_exists:
×
UNCOV
81
            s += " IF NOT EXISTS"
×
82

UNCOV
83
        s += " " + self._name
×
84

UNCOV
85
        if self._query is not None:
×
86
            s += f" FROM ({self._query})"
×
87

UNCOV
88
        if self._function_type is not None:
×
UNCOV
89
            s += " TYPE " + str(self._function_type)
×
90

UNCOV
91
        if self._impl_path:
×
UNCOV
92
            s += f" IMPL {self._impl_path.name}"
×
93

UNCOV
94
        if self._metadata is not None:
×
UNCOV
95
            for key, value in self._metadata:
×
96
                # NOTE :- Removing quotes around key and making it upper case
97
                # Since in tests we are doing a straight string comparison
UNCOV
98
                s += f" {key.upper()} '{value}'"
×
UNCOV
99
        return s
×
100

UNCOV
101
    @property
×
UNCOV
102
    def name(self):
×
UNCOV
103
        return self._name
×
104

UNCOV
105
    @property
×
UNCOV
106
    def or_replace(self):
×
UNCOV
107
        return self._or_replace
×
108

UNCOV
109
    @property
×
UNCOV
110
    def if_not_exists(self):
×
UNCOV
111
        return self._if_not_exists
×
112

UNCOV
113
    @property
×
UNCOV
114
    def inputs(self):
×
UNCOV
115
        return self._inputs
×
116

UNCOV
117
    @inputs.setter
×
UNCOV
118
    def inputs(self, value):
×
119
        self._inputs = value
×
120

UNCOV
121
    @property
×
UNCOV
122
    def outputs(self):
×
UNCOV
123
        return self._outputs
×
124

UNCOV
125
    @outputs.setter
×
UNCOV
126
    def outputs(self, value):
×
127
        self._outputs = value
×
128

UNCOV
129
    @property
×
UNCOV
130
    def impl_path(self):
×
UNCOV
131
        return self._impl_path
×
132

UNCOV
133
    @property
×
UNCOV
134
    def function_type(self):
×
UNCOV
135
        return self._function_type
×
136

UNCOV
137
    @property
×
UNCOV
138
    def query(self):
×
UNCOV
139
        return self._query
×
140

UNCOV
141
    @property
×
UNCOV
142
    def metadata(self):
×
UNCOV
143
        return self._metadata
×
144

UNCOV
145
    def __eq__(self, other):
×
UNCOV
146
        if not isinstance(other, CreateFunctionStatement):
×
UNCOV
147
            return False
×
UNCOV
148
        return (
×
149
            self.name == other.name
150
            and self.or_replace == other.or_replace
151
            and self.if_not_exists == other.if_not_exists
152
            and self.inputs == other.inputs
153
            and self.outputs == other.outputs
154
            and self.impl_path == other.impl_path
155
            and self.function_type == other.function_type
156
            and self.query == other.query
157
            and self.metadata == other.metadata
158
        )
159

UNCOV
160
    def __hash__(self) -> int:
×
UNCOV
161
        return hash(
×
162
            (
163
                super().__hash__(),
164
                self.name,
165
                self.or_replace,
166
                self.if_not_exists,
167
                tuple(self.inputs),
168
                tuple(self.outputs),
169
                self.impl_path,
170
                self.function_type,
171
                self.query,
172
                tuple(self.metadata),
173
            )
174
        )
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