• 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/interfaces/relational/utils.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 Callable, List, Union
×
16

17
from evadb.binder.statement_binder import StatementBinder
×
18
from evadb.binder.statement_binder_context import StatementBinderContext
×
19
from evadb.expression.abstract_expression import AbstractExpression
×
20
from evadb.expression.constant_value_expression import ConstantValueExpression
×
21
from evadb.expression.tuple_value_expression import TupleValueExpression
×
22
from evadb.parser.select_statement import SelectStatement
×
23
from evadb.parser.statement import AbstractStatement
×
24
from evadb.parser.table_ref import TableRef
×
25
from evadb.parser.utils import (
×
26
    parse_expression,
27
    parse_lateral_join,
28
    parse_predicate_expression,
29
)
30

31

32
def sql_string_to_expresssion_list(expr: str) -> List[AbstractExpression]:
×
33
    """Converts the sql expression to list of evadb abstract expressions
34

35
    Args:
36
        expr (str): the expr to convert
37

38
    Returns:
39
        List[AbstractExpression]: list of evadb abstract expressions
40

41
    """
42
    return parse_expression(expr)
×
43

44

45
def sql_predicate_to_expresssion_tree(expr: str) -> AbstractExpression:
×
46
    return parse_predicate_expression(expr)
×
47

48

49
def string_to_lateral_join(expr: str, alias: str):
×
50
    return parse_lateral_join(expr, alias)
×
51

52

53
def create_star_expression():
×
54
    return [TupleValueExpression(name="*")]
×
55

56

57
def create_limit_expression(num: int):
×
58
    return ConstantValueExpression(num)
×
59

60

61
def try_binding(catalog: Callable, stmt: AbstractStatement):
×
62
    # To avoid complications in subsequent binder calls, we attempt to bind a copy of
63
    # the statement since the binder modifies the statement in place and can cause
64
    # issues if statement is partially bound.
65
    StatementBinder(StatementBinderContext(catalog)).bind(stmt.copy())
×
66

67

68
def handle_select_clause(
×
69
    query: SelectStatement, alias: str, clause: str, value: Union[str, int, list]
70
) -> SelectStatement:
71
    """
72
    Modifies a SELECT statement object by adding or modifying a specific clause.
73

74
    Args:
75
        query (SelectStatement): The SELECT statement object.
76
        alias (str): Alias for the table reference.
77
        clause (str): The clause to be handled.
78
        value (str, int, list): The value to be set for the clause.
79

80
    Returns:
81
        SelectStatement: The modified SELECT statement object.
82

83
    Raises:
84
        AssertionError: If the query is not an instance of SelectStatement class.
85
        AssertionError: If the clause is not in the accepted clauses list.
86
    """
87

88
    assert isinstance(
×
89
        query, SelectStatement
90
    ), "query must be an instance of SelectStatement"
91

92
    accepted_clauses = [
×
93
        "where_clause",
94
        "target_list",
95
        "groupby_clause",
96
        "orderby_list",
97
        "limit_count",
98
    ]
99

100
    assert clause in accepted_clauses, f"Unknown clause: {clause}"
×
101

102
    # If the clause being set is "target_list" and the value is equal to
103
    # "*", the "SELECT *" portion is replaced by SELECT <value>.
104
    if clause == "target_list" and getattr(query, clause) == create_star_expression():
×
105
        setattr(query, clause, None)
×
106

107
    if getattr(query, clause) is None:
×
108
        setattr(query, clause, value)
×
109
    else:
110
        query = SelectStatement(
×
111
            target_list=create_star_expression(),
112
            from_table=TableRef(query, alias=alias),
113
        )
114
        setattr(query, clause, value)
×
115

116
    return query
×
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