Skip to content

Commit f0d2b76

Browse files
author
oleksandr.volha
committed
fixes
1 parent 8727c86 commit f0d2b76

File tree

13 files changed

+27
-45
lines changed

13 files changed

+27
-45
lines changed

uncoder-core/app/translator/core/custom_types/functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class FunctionType(CustomEnum):
2222
upper = "upper"
2323

2424
array_length = "array_length"
25-
compare = "compare"
2625
extract_time = "extract_time"
2726
ipv4_is_in_range = "ipv4_is_in_range"
2827

uncoder-core/app/translator/core/functions.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
from app.translator.core.exceptions.functions import NotSupportedFunctionException
2727
from app.translator.core.mapping import SourceMapping
28-
from app.translator.core.models.field import Alias, Field
2928
from app.translator.core.models.functions.base import Function, ParsedFunctions, RenderedFunctions
29+
from app.translator.core.models.query_tokens.field import Alias, Field
3030
from app.translator.tools.utils import execute_module
3131
from settings import INIT_FUNCTIONS
3232

@@ -83,7 +83,6 @@ def parse(self, func_body: str, raw: str) -> Function:
8383
class FunctionRender(ABC):
8484
function_names_map: ClassVar[dict[str, str]] = {}
8585
order_to_render: int = 0
86-
in_query_render: bool = False
8786
render_to_prefix: bool = False
8887
manager: PlatformFunctionsManager = None
8988

@@ -117,7 +116,6 @@ def __init__(self):
117116
self._parsers_map: dict[str, FunctionParser] = {} # {platform_func_name: FunctionParser}
118117

119118
self._renders_map: dict[str, FunctionRender] = {} # {generic_func_name: FunctionRender}
120-
self._in_query_renders_map: dict[str, FunctionRender] = {} # {generic_func_name: FunctionRender}
121119
self._order_to_render: dict[str, int] = {} # {generic_func_name: int}
122120

123121
def register_render(self, render_class: type[FunctionRender]) -> type[FunctionRender]:
@@ -126,8 +124,6 @@ def register_render(self, render_class: type[FunctionRender]) -> type[FunctionRe
126124
for generic_function_name in render.function_names_map:
127125
self._renders_map[generic_function_name] = render
128126
self._order_to_render[generic_function_name] = render.order_to_render
129-
if render.in_query_render:
130-
self._in_query_renders_map[generic_function_name] = render
131127

132128
return render_class
133129

@@ -149,24 +145,16 @@ def get_hof_parser(self, platform_func_name: str) -> HigherOrderFunctionParser:
149145

150146
raise NotSupportedFunctionException
151147

152-
def get_parser(self, platform_func_name: str) -> FunctionParser:
148+
def get_parser(self, platform_func_name: str) -> Optional[FunctionParser]:
153149
if INIT_FUNCTIONS and (parser := self._parsers_map.get(platform_func_name)):
154150
return parser
155151

156-
raise NotSupportedFunctionException
157-
158152
def get_render(self, generic_func_name: str) -> FunctionRender:
159153
if INIT_FUNCTIONS and (render := self._renders_map.get(generic_func_name)):
160154
return render
161155

162156
raise NotSupportedFunctionException
163157

164-
def get_in_query_render(self, generic_func_name: str) -> FunctionRender:
165-
if INIT_FUNCTIONS and (render := self._in_query_renders_map.get(generic_func_name)):
166-
return render
167-
168-
raise NotSupportedFunctionException
169-
170158
@property
171159
def order_to_render(self) -> dict[str, int]:
172160
if INIT_FUNCTIONS:

uncoder-core/app/translator/core/models/functions/base.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass, field
4-
from typing import Optional, Union
4+
from typing import TYPE_CHECKING, Optional, Union
55

6-
from app.translator.core.models.field import Alias, Field, FieldValue, Keyword
7-
from app.translator.core.models.identifier import Identifier
6+
from app.translator.core.models.query_tokens.field import Alias, Field
7+
from app.translator.core.models.query_tokens.field_field import FieldField
8+
from app.translator.core.models.query_tokens.field_value import FieldValue
9+
from app.translator.core.models.query_tokens.identifier import Identifier
10+
from app.translator.core.models.query_tokens.keyword import Keyword
11+
12+
if TYPE_CHECKING:
13+
from app.translator.core.models.query_tokens.function_value import FunctionValue
814

915

1016
@dataclass
1117
class Function:
1218
name: str = None
13-
args: list[Union[Alias, Field, FieldValue, Keyword, Function, Identifier, str, bool]] = field(default_factory=list)
19+
args: list[
20+
Union[Alias, Field, FieldField, FieldValue, FunctionValue, Keyword, Function, Identifier, int, str, bool]
21+
] = field(default_factory=list)
1422
alias: Optional[Alias] = None
1523
raw: str = ""
1624

uncoder-core/app/translator/core/models/functions/bin.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,15 @@
22
from typing import Optional
33

44
from app.translator.core.custom_types.functions import FunctionType
5-
from app.translator.core.models.field import Field
5+
from app.translator.core.custom_types.time import TimeFrameType
66
from app.translator.core.models.functions.base import Function
7-
from app.translator.tools.custom_enum import CustomEnum
8-
9-
10-
class SpanType(CustomEnum):
11-
days = "days"
12-
hours = "hours"
13-
minutes = "minutes"
7+
from app.translator.core.models.query_tokens.field import Field
148

159

1610
@dataclass
1711
class Span:
1812
value: str = "1"
19-
type_: str = SpanType.days
13+
type_: str = TimeFrameType.days
2014

2115

2216
@dataclass

uncoder-core/app/translator/core/models/functions/eval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from typing import Union
33

44
from app.translator.core.custom_types.functions import FunctionType
5-
from app.translator.core.models.field import Alias, Field
65
from app.translator.core.models.functions.base import Function
7-
from app.translator.core.models.identifier import Identifier
6+
from app.translator.core.models.query_tokens.field import Alias, Field
7+
from app.translator.core.models.query_tokens.identifier import Identifier
88

99

1010
@dataclass

uncoder-core/app/translator/core/models/functions/group_by.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from typing import Union
33

44
from app.translator.core.custom_types.functions import FunctionType
5-
from app.translator.core.models.field import Alias
65
from app.translator.core.models.functions.base import Function
6+
from app.translator.core.models.query_tokens.field import Alias
77

88

99
@dataclass

uncoder-core/app/translator/core/models/functions/join.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
from typing import Union
33

44
from app.translator.core.custom_types.functions import FunctionType
5-
from app.translator.core.models.field import Alias, Field
65
from app.translator.core.models.functions.base import Function
7-
from app.translator.core.models.identifier import Identifier
86
from app.translator.core.models.query_container import TokenizedQueryContainer
7+
from app.translator.core.models.query_tokens.field import Alias, Field
8+
from app.translator.core.models.query_tokens.identifier import Identifier
99
from app.translator.tools.custom_enum import CustomEnum
1010

1111

uncoder-core/app/translator/core/models/functions/rename.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from dataclasses import dataclass
22

33
from app.translator.core.custom_types.functions import FunctionType
4-
from app.translator.core.models.field import Alias, Field
54
from app.translator.core.models.functions.base import Function
5+
from app.translator.core.models.query_tokens.field import Alias, Field
66

77

88
@dataclass

uncoder-core/app/translator/core/models/functions/sort.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from typing import Union
33

44
from app.translator.core.custom_types.functions import FunctionType
5-
from app.translator.core.models.field import Alias, Field
65
from app.translator.core.models.functions.base import Function
6+
from app.translator.core.models.query_tokens.field import Alias, Field
77
from app.translator.tools.custom_enum import CustomEnum
88

99

uncoder-core/app/translator/core/models/functions/timeframe.py renamed to uncoder-core/app/translator/core/models/functions/time.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
from dataclasses import dataclass
22

33
from app.translator.core.custom_types.functions import FunctionType
4+
from app.translator.core.custom_types.time import TimeFrameType
45
from app.translator.core.models.functions.base import Function
5-
from app.translator.tools.custom_enum import CustomEnum
6-
7-
8-
class TimeFrameType(CustomEnum):
9-
days = "days"
10-
hours = "hours"
11-
minutes = "minutes"
126

137

148
@dataclass

0 commit comments

Comments
 (0)