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

georgia-tech-db / eva / a4c010ba-78be-4818-8e6f-1da08c6af280

31 Aug 2023 11:59PM UTC coverage: 70.992% (-10.6%) from 81.552%
a4c010ba-78be-4818-8e6f-1da08c6af280

push

circle-ci

web-flow
Merge branch 'staging' into evadb_staging

54 of 54 new or added lines in 3 files covered. (100.0%)

8020 of 11297 relevant lines covered (70.99%)

0.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.32
/evadb/expression/constant_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 Any
1✔
16

17
import numpy as np
1✔
18
import pandas as pd
1✔
19

20
from evadb.catalog.catalog_type import ColumnType
1✔
21
from evadb.expression.abstract_expression import AbstractExpression, ExpressionType
1✔
22
from evadb.models.storage.batch import Batch
1✔
23

24

25
class ConstantValueExpression(AbstractExpression):
1✔
26
    # Todo Implement generic value class
27
    # for now we don't assign any class to value
28
    # it can have types like string, int etc
29
    # return type not set, handle that based on value
30
    def __init__(self, value: Any, v_type: ColumnType = ColumnType.INTEGER):
1✔
31
        super().__init__(ExpressionType.CONSTANT_VALUE)
1✔
32
        self._value = value
1✔
33
        self._v_type = v_type
1✔
34

35
    def evaluate(self, batch: Batch, **kwargs):
1✔
36
        batch = Batch(pd.DataFrame({0: [self._value] * len(batch)}))
1✔
37
        return batch
1✔
38

39
    def signature(self) -> str:
1✔
40
        return str(self)
×
41

42
    @property
1✔
43
    def value(self):
1✔
44
        return self._value
1✔
45

46
    @property
1✔
47
    def v_type(self):
1✔
48
        return self._v_type
1✔
49

50
    # Todo implement other functionalities like maintaining hash
51
    # comparing two objects of this class(==)
52

53
    def __eq__(self, other):
1✔
54
        is_subtree_equal = super().__eq__(other)
×
55
        if not isinstance(other, ConstantValueExpression):
×
56
            return False
×
57
        # if the value type is NDARRAY, we need to reduce the
58
        # iterator to bool
59
        is_equal = is_subtree_equal and self.v_type == other.v_type
×
60

61
        if self.v_type == ColumnType.NDARRAY:
×
62
            return is_equal and all(self.value == other.value)
×
63
        else:
64
            return is_equal and self.value == other.value
×
65

66
    def __str__(self) -> str:
1✔
67
        expr_str = ""
1✔
68
        if not isinstance(self._value, np.ndarray):
1✔
69
            expr_str = f"{str(self._value)}"
1✔
70
        else:
71
            expr_str = f"{np.array_str(self._value)}"
×
72
        return expr_str
1✔
73

74
    def __hash__(self) -> int:
1✔
75
        return hash((super().__hash__(), self.v_type, str(self.value)))
1✔
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