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

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

23

24
class CreateUDFStatement(AbstractStatement):
×
25
    """Create UDF Statement constructed after parsing the input query
26

27
    Attributes:
28
        name: str
29
            udf_name provided by the user required
30
        if_not_exists: bool
31
            if true should throw an error if udf with same name exists
32
            else will replace the existing
33
        inputs: List[ColumnDefinition]
34
            udf inputs, represented similar to a table column definition
35
        outputs: List[ColumnDefinition]
36
            udf outputs, represented similar to a table column definition
37
        impl_file_path: str
38
            file path which holds the implementation of the udf.
39
            This file should be placed in the UDF directory and
40
            the path provided should be relative to the UDF dir.
41
        query: SelectStatement
42
            data source for the model train or fine tune.
43
        udf_type: str
44
            udf 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 udfs, mostly used for advanced udf types
47
    """
48

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

70
    def __str__(self) -> str:
×
71
        s = "CREATE UDF"
×
72

73
        if self._if_not_exists:
×
74
            s += " IF NOT EXISTS"
×
75

76
        s += " " + self._name
×
77

78
        if self._query is not None:
×
79
            s += f" FROM ({self._query})"
×
80

81
        if self._udf_type is not None:
×
82
            s += " TYPE " + str(self._udf_type)
×
83

84
        if self._impl_path:
×
85
            s += f" IMPL {self._impl_path.name}"
×
86

87
        if self._metadata is not None:
×
88
            for key, value in self._metadata:
×
89
                s += f" '{key}' '{value}'"
×
90
        return s
×
91

92
    @property
×
93
    def name(self):
×
94
        return self._name
×
95

96
    @property
×
97
    def if_not_exists(self):
×
98
        return self._if_not_exists
×
99

100
    @property
×
101
    def inputs(self):
×
102
        return self._inputs
×
103

104
    @inputs.setter
×
105
    def inputs(self, value):
×
106
        self._inputs = value
×
107

108
    @property
×
109
    def outputs(self):
×
110
        return self._outputs
×
111

112
    @outputs.setter
×
113
    def outputs(self, value):
×
114
        self._outputs = value
×
115

116
    @property
×
117
    def impl_path(self):
×
118
        return self._impl_path
×
119

120
    @property
×
121
    def udf_type(self):
×
122
        return self._udf_type
×
123

124
    @property
×
125
    def query(self):
×
126
        return self._query
×
127

128
    @property
×
129
    def metadata(self):
×
130
        return self._metadata
×
131

132
    def __eq__(self, other):
×
133
        if not isinstance(other, CreateUDFStatement):
×
134
            return False
×
135
        return (
×
136
            self.name == other.name
137
            and self.if_not_exists == other.if_not_exists
138
            and self.inputs == other.inputs
139
            and self.outputs == other.outputs
140
            and self.impl_path == other.impl_path
141
            and self.udf_type == other.udf_type
142
            and self.query == other.query
143
            and self.metadata == other.metadata
144
        )
145

146
    def __hash__(self) -> int:
×
147
        return hash(
×
148
            (
149
                super().__hash__(),
150
                self.name,
151
                self.if_not_exists,
152
                tuple(self.inputs),
153
                tuple(self.outputs),
154
                self.impl_path,
155
                self.udf_type,
156
                self.query,
157
                tuple(self.metadata),
158
            )
159
        )
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