pylegend 0.3.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pylegend/__init__.py +16 -6
- pylegend/core/{databse → database}/sql_to_string/__init__.py +3 -3
- pylegend/core/{databse → database}/sql_to_string/db_extension.py +14 -5
- pylegend/core/{databse → database}/sql_to_string/generator.py +2 -2
- pylegend/core/language/__init__.py +12 -10
- pylegend/core/language/legacy_api/__init__.py +13 -0
- pylegend/core/language/{aggregate_specification.py → legacy_api/aggregate_specification.py} +10 -10
- pylegend/core/language/legacy_api/legacy_api_tds_row.py +32 -0
- pylegend/core/language/legendql_api/__init__.py +13 -0
- pylegend/core/language/legendql_api/legendql_api_custom_expressions.py +541 -0
- pylegend/core/language/legendql_api/legendql_api_tds_row.py +292 -0
- pylegend/core/language/shared/__init__.py +13 -0
- pylegend/core/language/{column_expressions.py → shared/column_expressions.py} +32 -31
- pylegend/core/language/{expression.py → shared/expression.py} +8 -0
- pylegend/core/language/{functions.py → shared/functions.py} +12 -3
- pylegend/core/language/shared/helpers.py +75 -0
- pylegend/core/language/{literal_expressions.py → shared/literal_expressions.py} +39 -1
- pylegend/core/language/{operations → shared/operations}/binary_expression.py +34 -2
- pylegend/core/language/{operations → shared/operations}/boolean_operation_expressions.py +34 -6
- pylegend/core/language/{operations → shared/operations}/collection_operation_expressions.py +146 -26
- pylegend/core/language/{operations → shared/operations}/date_operation_expressions.py +288 -24
- pylegend/core/language/{operations → shared/operations}/float_operation_expressions.py +53 -8
- pylegend/core/language/{operations → shared/operations}/integer_operation_expressions.py +62 -9
- pylegend/core/language/{operations → shared/operations}/nullary_expression.py +9 -2
- pylegend/core/language/{operations → shared/operations}/number_operation_expressions.py +211 -30
- pylegend/core/language/shared/operations/primitive_operation_expressions.py +155 -0
- pylegend/core/language/{operations → shared/operations}/string_operation_expressions.py +194 -21
- pylegend/core/language/{operations → shared/operations}/unary_expression.py +10 -2
- pylegend/core/language/{primitive_collection.py → shared/primitive_collection.py} +2 -2
- pylegend/core/language/{primitives → shared/primitives}/__init__.py +9 -9
- pylegend/core/language/{primitives → shared/primitives}/boolean.py +9 -5
- pylegend/core/language/{primitives → shared/primitives}/date.py +60 -15
- pylegend/core/language/{primitives → shared/primitives}/datetime.py +4 -5
- pylegend/core/language/{primitives → shared/primitives}/float.py +6 -6
- pylegend/core/language/{primitives → shared/primitives}/integer.py +6 -6
- pylegend/core/language/{primitives → shared/primitives}/number.py +16 -13
- pylegend/core/language/{primitives → shared/primitives}/primitive.py +41 -5
- pylegend/core/language/{primitives → shared/primitives}/strictdate.py +4 -5
- pylegend/core/language/{primitives → shared/primitives}/string.py +18 -19
- pylegend/core/language/{tds_row.py → shared/tds_row.py} +46 -16
- pylegend/core/request/__init__.py +7 -1
- pylegend/core/request/auth.py +55 -1
- pylegend/core/request/legend_client.py +32 -0
- pylegend/core/sql/metamodel_extension.py +28 -0
- pylegend/core/tds/abstract/__init__.py +13 -0
- pylegend/core/tds/abstract/frames/__init__.py +13 -0
- pylegend/core/tds/{legend_api/frames/legend_api_applied_function_tds_frame.py → abstract/frames/applied_function_tds_frame.py} +19 -13
- pylegend/core/tds/abstract/frames/base_tds_frame.py +125 -0
- pylegend/core/tds/{legend_api/frames/legend_api_input_tds_frame.py → abstract/frames/input_tds_frame.py} +9 -12
- pylegend/core/tds/{legend_api/frames/functions → abstract}/function_helpers.py +1 -1
- pylegend/core/tds/{legend_api/frames/functions/concatenate_function.py → legacy_api/frames/functions/legacy_api_concatenate_function.py} +25 -13
- pylegend/core/tds/{legend_api/frames/functions/distinct_function.py → legacy_api/frames/functions/legacy_api_distinct_function.py} +13 -8
- pylegend/core/tds/{legend_api/frames/functions/drop_function.py → legacy_api/frames/functions/legacy_api_drop_function.py} +13 -8
- pylegend/core/tds/{legend_api/frames/functions/extend_function.py → legacy_api/frames/functions/legacy_api_extend_function.py} +36 -16
- pylegend/core/tds/{legend_api/frames/functions/filter_function.py → legacy_api/frames/functions/legacy_api_filter_function.py} +25 -13
- pylegend/core/tds/{legend_api/frames/functions/group_by_function.py → legacy_api/frames/functions/legacy_api_group_by_function.py} +44 -17
- pylegend/core/tds/{legend_api/frames/functions/head_function.py → legacy_api/frames/functions/legacy_api_head_function.py} +13 -8
- pylegend/core/tds/{legend_api/frames/functions/join_by_columns_function.py → legacy_api/frames/functions/legacy_api_join_by_columns_function.py} +40 -13
- pylegend/core/tds/{legend_api/frames/functions/join_function.py → legacy_api/frames/functions/legacy_api_join_function.py} +44 -20
- pylegend/core/tds/{legend_api/frames/functions/rename_columns_function.py → legacy_api/frames/functions/legacy_api_rename_columns_function.py} +20 -8
- pylegend/core/tds/{legend_api/frames/functions/restrict_function.py → legacy_api/frames/functions/legacy_api_restrict_function.py} +17 -8
- pylegend/core/tds/{legend_api/frames/functions/slice_function.py → legacy_api/frames/functions/legacy_api_slice_function.py} +13 -8
- pylegend/core/tds/{legend_api/frames/functions/sort_function.py → legacy_api/frames/functions/legacy_api_sort_function.py} +19 -8
- pylegend/core/tds/legacy_api/frames/legacy_api_applied_function_tds_frame.py +37 -0
- pylegend/core/tds/legacy_api/frames/legacy_api_base_tds_frame.py +204 -0
- pylegend/core/tds/legacy_api/frames/legacy_api_input_tds_frame.py +51 -0
- pylegend/core/tds/{legend_api/frames/legend_api_tds_frame.py → legacy_api/frames/legacy_api_tds_frame.py} +28 -28
- pylegend/core/tds/legendql_api/__init__.py +13 -0
- pylegend/core/tds/legendql_api/frames/__init__.py +13 -0
- pylegend/core/tds/legendql_api/frames/functions/__init__.py +13 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_asofjoin_function.py +156 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_concatenate_function.py +139 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_distinct_function.py +69 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_drop_function.py +74 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_extend_function.py +256 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_filter_function.py +121 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_function_helpers.py +137 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_groupby_function.py +256 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_head_function.py +74 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_join_function.py +214 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_project_function.py +169 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_rename_function.py +189 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_select_function.py +131 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_slice_function.py +82 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_sort_function.py +93 -0
- pylegend/core/tds/legendql_api/frames/functions/legendql_api_window_extend_function.py +283 -0
- pylegend/core/tds/legendql_api/frames/legendql_api_applied_function_tds_frame.py +37 -0
- pylegend/core/tds/legendql_api/frames/legendql_api_base_tds_frame.py +419 -0
- pylegend/core/tds/legendql_api/frames/legendql_api_input_tds_frame.py +50 -0
- pylegend/core/tds/legendql_api/frames/legendql_api_tds_frame.py +327 -0
- pylegend/core/tds/pandas_api/frames/functions/assign_function.py +6 -6
- pylegend/core/tds/pandas_api/frames/pandas_api_applied_function_tds_frame.py +4 -0
- pylegend/core/tds/pandas_api/frames/pandas_api_base_tds_frame.py +11 -3
- pylegend/core/tds/pandas_api/frames/pandas_api_tds_frame.py +2 -2
- pylegend/core/tds/tds_frame.py +32 -2
- pylegend/extensions/database/vendors/postgres/postgres_sql_to_string.py +1 -1
- pylegend/extensions/tds/abstract/legend_function_input_frame.py +4 -0
- pylegend/extensions/tds/abstract/legend_service_input_frame.py +4 -0
- pylegend/extensions/tds/abstract/table_spec_input_frame.py +4 -0
- pylegend/extensions/tds/{legend_api/frames/legend_api_legend_function_input_frame.py → legacy_api/frames/legacy_api_legend_function_input_frame.py} +5 -5
- pylegend/extensions/tds/{legend_api/frames/legend_api_legend_service_input_frame.py → legacy_api/frames/legacy_api_legend_service_input_frame.py} +6 -6
- pylegend/extensions/tds/{legend_api/frames/legend_api_table_spec_input_frame.py → legacy_api/frames/legacy_api_table_spec_input_frame.py} +5 -5
- pylegend/extensions/tds/legendql_api/__init__.py +13 -0
- pylegend/extensions/tds/legendql_api/frames/__init__.py +13 -0
- pylegend/extensions/tds/legendql_api/frames/legendql_api_legend_service_input_frame.py +46 -0
- pylegend/extensions/tds/legendql_api/frames/legendql_api_table_spec_input_frame.py +36 -0
- pylegend/{legend_api_tds_client.py → legacy_api_tds_client.py} +15 -15
- {pylegend-0.3.0.dist-info → pylegend-0.5.0.dist-info}/METADATA +7 -8
- pylegend-0.5.0.dist-info/NOTICE +5 -0
- pylegend-0.5.0.dist-info/RECORD +155 -0
- {pylegend-0.3.0.dist-info → pylegend-0.5.0.dist-info}/WHEEL +1 -1
- pylegend/core/language/operations/primitive_operation_expressions.py +0 -56
- pylegend/core/tds/legend_api/frames/legend_api_base_tds_frame.py +0 -294
- pylegend-0.3.0.dist-info/RECORD +0 -115
- /pylegend/core/{databse → database}/__init__.py +0 -0
- /pylegend/core/{databse → database}/sql_to_string/config.py +0 -0
- /pylegend/core/language/{operations → shared/operations}/__init__.py +0 -0
- /pylegend/core/tds/{legend_api → legacy_api}/__init__.py +0 -0
- /pylegend/core/tds/{legend_api → legacy_api}/frames/__init__.py +0 -0
- /pylegend/core/tds/{legend_api → legacy_api}/frames/functions/__init__.py +0 -0
- /pylegend/extensions/tds/{legend_api → legacy_api}/__init__.py +0 -0
- /pylegend/extensions/tds/{legend_api → legacy_api}/frames/__init__.py +0 -0
- {pylegend-0.3.0.dist-info → pylegend-0.5.0.dist-info}/LICENSE +0 -0
- {pylegend-0.3.0.dist-info → pylegend-0.5.0.dist-info}/LICENSE.spdx +0 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
# Copyright 2025 Goldman Sachs
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from abc import ABCMeta
|
|
16
|
+
from pylegend._typing import (
|
|
17
|
+
PyLegendSequence,
|
|
18
|
+
PyLegendTypeVar,
|
|
19
|
+
PyLegendCallable,
|
|
20
|
+
PyLegendUnion,
|
|
21
|
+
PyLegendList,
|
|
22
|
+
PyLegendTuple,
|
|
23
|
+
PyLegendOptional,
|
|
24
|
+
)
|
|
25
|
+
from pylegend.core.language import PyLegendBoolean, PyLegendPrimitiveOrPythonPrimitive, PyLegendPrimitiveCollection, \
|
|
26
|
+
PyLegendPrimitive
|
|
27
|
+
from pylegend.core.language.legendql_api.legendql_api_custom_expressions import (
|
|
28
|
+
LegendQLApiPrimitive,
|
|
29
|
+
LegendQLApiSortInfo,
|
|
30
|
+
LegendQLApiWindow,
|
|
31
|
+
LegendQLApiPartialFrame,
|
|
32
|
+
LegendQLApiWindowReference,
|
|
33
|
+
)
|
|
34
|
+
from pylegend.core.language.legendql_api.legendql_api_tds_row import LegendQLApiTdsRow
|
|
35
|
+
from pylegend.core.tds.abstract.frames.base_tds_frame import BaseTdsFrame
|
|
36
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_tds_frame import LegendQLApiTdsFrame
|
|
37
|
+
from pylegend.core.tds.tds_column import TdsColumn
|
|
38
|
+
|
|
39
|
+
__all__: PyLegendSequence[str] = [
|
|
40
|
+
"LegendQLApiBaseTdsFrame"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
R = PyLegendTypeVar('R')
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class LegendQLApiBaseTdsFrame(LegendQLApiTdsFrame, BaseTdsFrame, metaclass=ABCMeta):
|
|
47
|
+
def __init__(self, columns: PyLegendSequence[TdsColumn]) -> None:
|
|
48
|
+
BaseTdsFrame.__init__(self, columns=columns)
|
|
49
|
+
|
|
50
|
+
def head(self, row_count: int = 5) -> "LegendQLApiTdsFrame":
|
|
51
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
52
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
53
|
+
)
|
|
54
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_head_function import (
|
|
55
|
+
LegendQLApiHeadFunction
|
|
56
|
+
)
|
|
57
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiHeadFunction(self, row_count))
|
|
58
|
+
|
|
59
|
+
def limit(self, row_count: int = 5) -> "LegendQLApiTdsFrame":
|
|
60
|
+
return self.head(row_count=row_count)
|
|
61
|
+
|
|
62
|
+
def distinct(self) -> "LegendQLApiTdsFrame":
|
|
63
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
64
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
65
|
+
)
|
|
66
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_distinct_function import (
|
|
67
|
+
LegendQLApiDistinctFunction
|
|
68
|
+
)
|
|
69
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiDistinctFunction(self))
|
|
70
|
+
|
|
71
|
+
def select(
|
|
72
|
+
self,
|
|
73
|
+
columns: PyLegendUnion[
|
|
74
|
+
str,
|
|
75
|
+
PyLegendList[str],
|
|
76
|
+
PyLegendCallable[
|
|
77
|
+
[LegendQLApiTdsRow],
|
|
78
|
+
PyLegendUnion[LegendQLApiPrimitive, PyLegendList[LegendQLApiPrimitive]]
|
|
79
|
+
]
|
|
80
|
+
]
|
|
81
|
+
) -> "LegendQLApiTdsFrame":
|
|
82
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
83
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
84
|
+
)
|
|
85
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_select_function import (
|
|
86
|
+
LegendQLApiSelectFunction
|
|
87
|
+
)
|
|
88
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiSelectFunction(self, columns))
|
|
89
|
+
|
|
90
|
+
def drop(self, count: int = 5) -> "LegendQLApiTdsFrame":
|
|
91
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
92
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
93
|
+
)
|
|
94
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_drop_function import (
|
|
95
|
+
LegendQLApiDropFunction
|
|
96
|
+
)
|
|
97
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiDropFunction(self, count))
|
|
98
|
+
|
|
99
|
+
def slice(self, start_row: int, end_row_exclusive: int) -> "LegendQLApiTdsFrame":
|
|
100
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
101
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
102
|
+
)
|
|
103
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_slice_function import (
|
|
104
|
+
LegendQLApiSliceFunction
|
|
105
|
+
)
|
|
106
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiSliceFunction(self, start_row, end_row_exclusive))
|
|
107
|
+
|
|
108
|
+
def sort(
|
|
109
|
+
self,
|
|
110
|
+
sort_infos: PyLegendUnion[
|
|
111
|
+
str,
|
|
112
|
+
PyLegendList[str],
|
|
113
|
+
PyLegendCallable[
|
|
114
|
+
[LegendQLApiTdsRow],
|
|
115
|
+
PyLegendUnion[
|
|
116
|
+
LegendQLApiPrimitive,
|
|
117
|
+
LegendQLApiSortInfo,
|
|
118
|
+
PyLegendList[PyLegendUnion[LegendQLApiPrimitive, LegendQLApiSortInfo]],
|
|
119
|
+
]
|
|
120
|
+
]
|
|
121
|
+
]
|
|
122
|
+
) -> "LegendQLApiTdsFrame":
|
|
123
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
124
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
125
|
+
)
|
|
126
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_sort_function import (
|
|
127
|
+
LegendQLApiSortFunction
|
|
128
|
+
)
|
|
129
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiSortFunction(self, sort_infos))
|
|
130
|
+
|
|
131
|
+
def concatenate(self, other: "LegendQLApiTdsFrame") -> "LegendQLApiTdsFrame":
|
|
132
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
133
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
134
|
+
)
|
|
135
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_concatenate_function import (
|
|
136
|
+
LegendQLApiConcatenateFunction
|
|
137
|
+
)
|
|
138
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiConcatenateFunction(self, other))
|
|
139
|
+
|
|
140
|
+
def filter(
|
|
141
|
+
self,
|
|
142
|
+
filter_function: PyLegendCallable[[LegendQLApiTdsRow], PyLegendUnion[bool, PyLegendBoolean]]
|
|
143
|
+
) -> "LegendQLApiTdsFrame":
|
|
144
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
145
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
146
|
+
)
|
|
147
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_filter_function import (
|
|
148
|
+
LegendQLApiFilterFunction
|
|
149
|
+
)
|
|
150
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiFilterFunction(self, filter_function))
|
|
151
|
+
|
|
152
|
+
def rename(
|
|
153
|
+
self,
|
|
154
|
+
column_renames: PyLegendUnion[
|
|
155
|
+
PyLegendTuple[str, str],
|
|
156
|
+
PyLegendList[PyLegendTuple[str, str]],
|
|
157
|
+
PyLegendCallable[
|
|
158
|
+
[LegendQLApiTdsRow],
|
|
159
|
+
PyLegendUnion[
|
|
160
|
+
PyLegendTuple[LegendQLApiPrimitive, str],
|
|
161
|
+
PyLegendList[PyLegendTuple[LegendQLApiPrimitive, str]]
|
|
162
|
+
]
|
|
163
|
+
]
|
|
164
|
+
]
|
|
165
|
+
) -> "LegendQLApiTdsFrame":
|
|
166
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
167
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
168
|
+
)
|
|
169
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_rename_function import (
|
|
170
|
+
LegendQLApiRenameFunction
|
|
171
|
+
)
|
|
172
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiRenameFunction(self, column_renames))
|
|
173
|
+
|
|
174
|
+
def extend(
|
|
175
|
+
self,
|
|
176
|
+
extend_columns: PyLegendUnion[
|
|
177
|
+
PyLegendTuple[
|
|
178
|
+
str,
|
|
179
|
+
PyLegendCallable[[LegendQLApiTdsRow], PyLegendPrimitiveOrPythonPrimitive]
|
|
180
|
+
],
|
|
181
|
+
PyLegendTuple[
|
|
182
|
+
str,
|
|
183
|
+
PyLegendCallable[[LegendQLApiTdsRow], PyLegendPrimitiveOrPythonPrimitive],
|
|
184
|
+
PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive]
|
|
185
|
+
],
|
|
186
|
+
PyLegendList[
|
|
187
|
+
PyLegendUnion[
|
|
188
|
+
PyLegendTuple[
|
|
189
|
+
str,
|
|
190
|
+
PyLegendCallable[[LegendQLApiTdsRow], PyLegendPrimitiveOrPythonPrimitive]
|
|
191
|
+
],
|
|
192
|
+
PyLegendTuple[
|
|
193
|
+
str,
|
|
194
|
+
PyLegendCallable[[LegendQLApiTdsRow], PyLegendPrimitiveOrPythonPrimitive],
|
|
195
|
+
PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive]
|
|
196
|
+
]
|
|
197
|
+
]
|
|
198
|
+
]
|
|
199
|
+
]
|
|
200
|
+
) -> "LegendQLApiTdsFrame":
|
|
201
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
202
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
203
|
+
)
|
|
204
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_extend_function import (
|
|
205
|
+
LegendQLApiExtendFunction
|
|
206
|
+
)
|
|
207
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiExtendFunction(self, extend_columns))
|
|
208
|
+
|
|
209
|
+
def join(
|
|
210
|
+
self,
|
|
211
|
+
other: "LegendQLApiTdsFrame",
|
|
212
|
+
join_condition: PyLegendCallable[
|
|
213
|
+
[LegendQLApiTdsRow, LegendQLApiTdsRow], PyLegendUnion[bool, PyLegendBoolean]
|
|
214
|
+
],
|
|
215
|
+
join_type: str = 'LEFT_OUTER'
|
|
216
|
+
) -> "LegendQLApiTdsFrame":
|
|
217
|
+
|
|
218
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
219
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
220
|
+
)
|
|
221
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_join_function import (
|
|
222
|
+
LegendQLApiJoinFunction
|
|
223
|
+
)
|
|
224
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiJoinFunction(self, other, join_condition, join_type))
|
|
225
|
+
|
|
226
|
+
def inner_join(
|
|
227
|
+
self,
|
|
228
|
+
other: "LegendQLApiTdsFrame",
|
|
229
|
+
join_condition: PyLegendCallable[
|
|
230
|
+
[LegendQLApiTdsRow, LegendQLApiTdsRow], PyLegendUnion[bool, PyLegendBoolean]
|
|
231
|
+
]
|
|
232
|
+
) -> "LegendQLApiTdsFrame":
|
|
233
|
+
return self.join(other, join_condition, "INNER")
|
|
234
|
+
|
|
235
|
+
def left_join(
|
|
236
|
+
self,
|
|
237
|
+
other: "LegendQLApiTdsFrame",
|
|
238
|
+
join_condition: PyLegendCallable[
|
|
239
|
+
[LegendQLApiTdsRow, LegendQLApiTdsRow], PyLegendUnion[bool, PyLegendBoolean]
|
|
240
|
+
]
|
|
241
|
+
) -> "LegendQLApiTdsFrame":
|
|
242
|
+
return self.join(other, join_condition, "LEFT_OUTER")
|
|
243
|
+
|
|
244
|
+
def right_join(
|
|
245
|
+
self,
|
|
246
|
+
other: "LegendQLApiTdsFrame",
|
|
247
|
+
join_condition: PyLegendCallable[
|
|
248
|
+
[LegendQLApiTdsRow, LegendQLApiTdsRow], PyLegendUnion[bool, PyLegendBoolean]
|
|
249
|
+
]
|
|
250
|
+
) -> "LegendQLApiTdsFrame":
|
|
251
|
+
return self.join(other, join_condition, "RIGHT_OUTER")
|
|
252
|
+
|
|
253
|
+
def as_of_join(
|
|
254
|
+
self,
|
|
255
|
+
other: "LegendQLApiTdsFrame",
|
|
256
|
+
match_function: PyLegendCallable[
|
|
257
|
+
[LegendQLApiTdsRow, LegendQLApiTdsRow], PyLegendUnion[bool, PyLegendBoolean]
|
|
258
|
+
],
|
|
259
|
+
join_condition: PyLegendOptional[
|
|
260
|
+
PyLegendCallable[[LegendQLApiTdsRow, LegendQLApiTdsRow], PyLegendUnion[bool, PyLegendBoolean]]
|
|
261
|
+
] = None
|
|
262
|
+
) -> "LegendQLApiTdsFrame":
|
|
263
|
+
|
|
264
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
265
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
266
|
+
)
|
|
267
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_asofjoin_function import (
|
|
268
|
+
LegendQLApiAsOfJoinFunction
|
|
269
|
+
)
|
|
270
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiAsOfJoinFunction(self, other, match_function, join_condition))
|
|
271
|
+
|
|
272
|
+
def group_by(
|
|
273
|
+
self,
|
|
274
|
+
grouping_columns: PyLegendUnion[
|
|
275
|
+
str,
|
|
276
|
+
PyLegendList[str],
|
|
277
|
+
PyLegendCallable[
|
|
278
|
+
[LegendQLApiTdsRow],
|
|
279
|
+
PyLegendUnion[LegendQLApiPrimitive, PyLegendList[LegendQLApiPrimitive]]
|
|
280
|
+
]
|
|
281
|
+
],
|
|
282
|
+
aggregate_specifications: PyLegendUnion[
|
|
283
|
+
PyLegendTuple[
|
|
284
|
+
str,
|
|
285
|
+
PyLegendCallable[[LegendQLApiTdsRow], PyLegendPrimitiveOrPythonPrimitive],
|
|
286
|
+
PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive]
|
|
287
|
+
],
|
|
288
|
+
PyLegendList[
|
|
289
|
+
PyLegendTuple[
|
|
290
|
+
str,
|
|
291
|
+
PyLegendCallable[[LegendQLApiTdsRow], PyLegendPrimitiveOrPythonPrimitive],
|
|
292
|
+
PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive]
|
|
293
|
+
]
|
|
294
|
+
]
|
|
295
|
+
]
|
|
296
|
+
) -> "LegendQLApiTdsFrame":
|
|
297
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
298
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
299
|
+
)
|
|
300
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_groupby_function import (
|
|
301
|
+
LegendQLApiGroupByFunction
|
|
302
|
+
)
|
|
303
|
+
return LegendQLApiAppliedFunctionTdsFrame(
|
|
304
|
+
LegendQLApiGroupByFunction(self, grouping_columns, aggregate_specifications)
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
def window(
|
|
308
|
+
self,
|
|
309
|
+
partition_by: PyLegendOptional[
|
|
310
|
+
PyLegendUnion[
|
|
311
|
+
str,
|
|
312
|
+
PyLegendList[str],
|
|
313
|
+
PyLegendCallable[
|
|
314
|
+
[LegendQLApiTdsRow],
|
|
315
|
+
PyLegendUnion[LegendQLApiPrimitive, PyLegendList[LegendQLApiPrimitive]]
|
|
316
|
+
]
|
|
317
|
+
]
|
|
318
|
+
] = None,
|
|
319
|
+
order_by: PyLegendOptional[
|
|
320
|
+
PyLegendUnion[
|
|
321
|
+
str,
|
|
322
|
+
PyLegendList[str],
|
|
323
|
+
PyLegendCallable[
|
|
324
|
+
[LegendQLApiTdsRow],
|
|
325
|
+
PyLegendUnion[
|
|
326
|
+
LegendQLApiPrimitive,
|
|
327
|
+
LegendQLApiSortInfo,
|
|
328
|
+
PyLegendList[PyLegendUnion[LegendQLApiPrimitive, LegendQLApiSortInfo]],
|
|
329
|
+
]
|
|
330
|
+
]
|
|
331
|
+
]
|
|
332
|
+
] = None
|
|
333
|
+
) -> "LegendQLApiWindow":
|
|
334
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_function_helpers import (
|
|
335
|
+
infer_columns_from_frame,
|
|
336
|
+
infer_sorts_from_frame,
|
|
337
|
+
)
|
|
338
|
+
return LegendQLApiWindow(
|
|
339
|
+
partition_by=(
|
|
340
|
+
None if partition_by is None else
|
|
341
|
+
infer_columns_from_frame(self, partition_by, "'window' function partition_by")
|
|
342
|
+
),
|
|
343
|
+
order_by=(
|
|
344
|
+
None if order_by is None else
|
|
345
|
+
infer_sorts_from_frame(self, order_by, "'window' function order_by")
|
|
346
|
+
),
|
|
347
|
+
frame=None
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
def window_extend(
|
|
351
|
+
self,
|
|
352
|
+
window: LegendQLApiWindow,
|
|
353
|
+
extend_columns: PyLegendUnion[
|
|
354
|
+
PyLegendTuple[
|
|
355
|
+
str,
|
|
356
|
+
PyLegendCallable[
|
|
357
|
+
[LegendQLApiPartialFrame, LegendQLApiWindowReference, LegendQLApiTdsRow],
|
|
358
|
+
PyLegendPrimitiveOrPythonPrimitive
|
|
359
|
+
]
|
|
360
|
+
],
|
|
361
|
+
PyLegendTuple[
|
|
362
|
+
str,
|
|
363
|
+
PyLegendCallable[
|
|
364
|
+
[LegendQLApiPartialFrame, LegendQLApiWindowReference, LegendQLApiTdsRow],
|
|
365
|
+
PyLegendPrimitiveOrPythonPrimitive
|
|
366
|
+
],
|
|
367
|
+
PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive]
|
|
368
|
+
],
|
|
369
|
+
PyLegendList[
|
|
370
|
+
PyLegendUnion[
|
|
371
|
+
PyLegendTuple[
|
|
372
|
+
str,
|
|
373
|
+
PyLegendCallable[
|
|
374
|
+
[LegendQLApiPartialFrame, LegendQLApiWindowReference, LegendQLApiTdsRow],
|
|
375
|
+
PyLegendPrimitiveOrPythonPrimitive
|
|
376
|
+
]
|
|
377
|
+
],
|
|
378
|
+
PyLegendTuple[
|
|
379
|
+
str,
|
|
380
|
+
PyLegendCallable[
|
|
381
|
+
[LegendQLApiPartialFrame, LegendQLApiWindowReference, LegendQLApiTdsRow],
|
|
382
|
+
PyLegendPrimitiveOrPythonPrimitive
|
|
383
|
+
],
|
|
384
|
+
PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive]
|
|
385
|
+
]
|
|
386
|
+
]
|
|
387
|
+
]
|
|
388
|
+
]
|
|
389
|
+
) -> "LegendQLApiTdsFrame":
|
|
390
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
391
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
392
|
+
)
|
|
393
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_window_extend_function import (
|
|
394
|
+
LegendQLApiWindowExtendFunction
|
|
395
|
+
)
|
|
396
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiWindowExtendFunction(self, window, extend_columns))
|
|
397
|
+
|
|
398
|
+
def project(
|
|
399
|
+
self,
|
|
400
|
+
project_columns: PyLegendUnion[
|
|
401
|
+
PyLegendTuple[
|
|
402
|
+
str,
|
|
403
|
+
PyLegendCallable[[LegendQLApiTdsRow], PyLegendPrimitiveOrPythonPrimitive]
|
|
404
|
+
],
|
|
405
|
+
PyLegendList[
|
|
406
|
+
PyLegendTuple[
|
|
407
|
+
str,
|
|
408
|
+
PyLegendCallable[[LegendQLApiTdsRow], PyLegendPrimitiveOrPythonPrimitive]
|
|
409
|
+
]
|
|
410
|
+
]
|
|
411
|
+
]
|
|
412
|
+
) -> "LegendQLApiTdsFrame":
|
|
413
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_applied_function_tds_frame import (
|
|
414
|
+
LegendQLApiAppliedFunctionTdsFrame
|
|
415
|
+
)
|
|
416
|
+
from pylegend.core.tds.legendql_api.frames.functions.legendql_api_project_function import (
|
|
417
|
+
LegendQLApiProjectFunction
|
|
418
|
+
)
|
|
419
|
+
return LegendQLApiAppliedFunctionTdsFrame(LegendQLApiProjectFunction(self, project_columns))
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Copyright 2025 Goldman Sachs
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from abc import ABCMeta
|
|
16
|
+
from pylegend._typing import (
|
|
17
|
+
PyLegendSequence
|
|
18
|
+
)
|
|
19
|
+
from pylegend.core.request.legend_client import LegendClient
|
|
20
|
+
from pylegend.core.tds.abstract.frames.input_tds_frame import (
|
|
21
|
+
InputTdsFrame,
|
|
22
|
+
ExecutableInputTdsFrame,
|
|
23
|
+
NonExecutableInputTdsFrame,
|
|
24
|
+
)
|
|
25
|
+
from pylegend.core.tds.legendql_api.frames.legendql_api_base_tds_frame import LegendQLApiBaseTdsFrame
|
|
26
|
+
from pylegend.core.tds.tds_column import TdsColumn
|
|
27
|
+
|
|
28
|
+
__all__: PyLegendSequence[str] = [
|
|
29
|
+
"LegendQLApiExecutableInputTdsFrame",
|
|
30
|
+
"LegendQLApiNonExecutableInputTdsFrame",
|
|
31
|
+
"LegendQLApiInputTdsFrame"
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class LegendQLApiInputTdsFrame(LegendQLApiBaseTdsFrame, InputTdsFrame, metaclass=ABCMeta):
|
|
36
|
+
def __init__(self, columns: PyLegendSequence[TdsColumn]) -> None:
|
|
37
|
+
LegendQLApiBaseTdsFrame.__init__(self, columns=columns)
|
|
38
|
+
InputTdsFrame.__init__(self, columns=columns)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class LegendQLApiExecutableInputTdsFrame(LegendQLApiInputTdsFrame, ExecutableInputTdsFrame, metaclass=ABCMeta):
|
|
42
|
+
def __init__(self, legend_client: LegendClient, columns: PyLegendSequence[TdsColumn]) -> None:
|
|
43
|
+
LegendQLApiInputTdsFrame.__init__(self, columns=columns)
|
|
44
|
+
ExecutableInputTdsFrame.__init__(self, legend_client=legend_client, columns=columns)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class LegendQLApiNonExecutableInputTdsFrame(LegendQLApiInputTdsFrame, NonExecutableInputTdsFrame, metaclass=ABCMeta):
|
|
48
|
+
def __init__(self, columns: PyLegendSequence[TdsColumn]) -> None:
|
|
49
|
+
LegendQLApiInputTdsFrame.__init__(self, columns=columns)
|
|
50
|
+
NonExecutableInputTdsFrame.__init__(self, columns=columns)
|