• 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/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.
UNCOV
15
from typing import Union
×
16

UNCOV
17
from evadb.catalog.models.column_catalog import ColumnCatalogEntry
×
UNCOV
18
from evadb.catalog.models.function_io_catalog import FunctionIOCatalogEntry
×
UNCOV
19
from evadb.models.storage.batch import Batch
×
20

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

27

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

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

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

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

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

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

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

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

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

UNCOV
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 function output columns it returns `function_name.col_name`
78
        Raises:
79
            ValueError: If the col_object is not a `Union[ColumnCatalogEntry, FunctionIOCatalogEntry]`. This can occur if the expression has not been bound using the binder.
80
        Returns:
81
            str: signature string
82
        """
UNCOV
83
        assert isinstance(self.col_object, ColumnCatalogEntry) or isinstance(
×
84
            self.col_object, FunctionIOCatalogEntry
85
        ), f"Unsupported type of self.col_object {type(self.col_object)}, expected ColumnCatalogEntry or FunctionIOCatalogEntry"
86

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

UNCOV
94
    def __eq__(self, other):
×
UNCOV
95
        is_subtree_equal = super().__eq__(other)
×
UNCOV
96
        if not isinstance(other, TupleValueExpression):
×
UNCOV
97
            return False
×
UNCOV
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

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

UNCOV
117
    def __hash__(self) -> int:
×
UNCOV
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

© 2026 Coveralls, Inc