• 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/expression/tuple_value_expression.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 Union
×
16

17
from evadb.catalog.models.column_catalog import ColumnCatalogEntry
×
18
from evadb.catalog.models.udf_io_catalog import UdfIOCatalogEntry
×
19
from evadb.models.storage.batch import Batch
×
20

21
from .abstract_expression import (
×
22
    AbstractExpression,
23
    ExpressionReturnType,
24
    ExpressionType,
25
)
26

27

28
class TupleValueExpression(AbstractExpression):
×
29
    def __init__(
×
30
        self,
31
        name: str = None,
32
        table_alias: str = None,
33
        col_object: Union[ColumnCatalogEntry, UdfIOCatalogEntry] = None,
34
        col_alias=None,
35
    ):
36
        super().__init__(ExpressionType.TUPLE_VALUE, rtype=ExpressionReturnType.INVALID)
×
37
        self._name = name
×
38
        self._table_alias = table_alias
×
39
        self._col_object = col_object
×
40
        self._col_alias = col_alias
×
41

42
    @property
×
43
    def table_alias(self) -> str:
×
44
        return self._table_alias
×
45

46
    @table_alias.setter
×
47
    def table_alias(self, table_alias):
×
48
        self._table_alias = table_alias
×
49

50
    @property
×
51
    def name(self) -> str:
×
52
        return self._name
×
53

54
    @property
×
55
    def col_object(self) -> Union[ColumnCatalogEntry, UdfIOCatalogEntry]:
×
56
        return self._col_object
×
57

58
    @col_object.setter
×
59
    def col_object(self, value: Union[ColumnCatalogEntry, UdfIOCatalogEntry]):
×
60
        self._col_object = value
×
61

62
    @property
×
63
    def col_alias(self) -> str:
×
64
        return self._col_alias
×
65

66
    @col_alias.setter
×
67
    def col_alias(self, value: str):
×
68
        self._col_alias = value
×
69

70
    def evaluate(self, batch: Batch, *args, **kwargs):
×
71
        return batch.project([self.col_alias])
×
72

73
    def signature(self):
×
74
        """It constructs the signature of the tuple value expression.
75
        It assumes the col_object attribute is populated by the binder with the catalog
76
        entries. For a standard column in the table, it returns `table_name.col_name`,
77
        and for UDF output columns it returns `udf_name.col_name`
78
        Raises:
79
            ValueError: If the col_object is not a `Union[ColumnCatalogEntry, UdfIOCatalogEntry]`. This can occur if the expression has not been bound using the binder.
80
        Returns:
81
            str: signature string
82
        """
83
        assert isinstance(self.col_object, ColumnCatalogEntry) or isinstance(
×
84
            self.col_object, UdfIOCatalogEntry
85
        ), f"Unsupported type of self.col_object {type(self.col_object)}, expected ColumnCatalogEntry or UdfIOCatalogEntry"
86

87
        col_name = self.col_object.name
×
88
        row_id = self.col_object.row_id
×
89
        if isinstance(self.col_object, ColumnCatalogEntry):
×
90
            return f"{self.col_object.table_name}.{col_name}[{row_id}]"
×
91
        elif isinstance(self.col_object, UdfIOCatalogEntry):
×
92
            return f"{self.col_object.udf_name}.{col_name}[{row_id}]"
×
93

94
    def __eq__(self, other):
×
95
        is_subtree_equal = super().__eq__(other)
×
96
        if not isinstance(other, TupleValueExpression):
×
97
            return False
×
98
        return (
×
99
            is_subtree_equal
100
            and self.table_alias == other.table_alias
101
            and self.name == other.name
102
            and self.col_alias == other.col_alias
103
            and self.col_object == other.col_object
104
        )
105

106
    def __str__(self) -> str:
×
107
        expr_str = ""
×
108
        if self.table_alias:
×
109
            expr_str += f"{str(self.table_alias)}."
×
110
        if self.name:
×
111
            expr_str += f"{str(self.name)}"
×
112
        if self.col_alias:
×
113
            expr_str += f" AS {str(self.col_alias)}"
×
114
        expr_str += ""
×
115
        return expr_str
×
116

117
    def __hash__(self) -> int:
×
118
        return hash(
×
119
            (
120
                super().__hash__(),
121
                self.table_alias,
122
                self.name,
123
                self.col_alias,
124
                self.col_object,
125
            )
126
        )
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