pylegend 0.2.2__py3-none-any.whl → 0.4.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 +9 -5
- pylegend/core/{databse → database}/sql_to_string/__init__.py +3 -3
- pylegend/core/{databse → database}/sql_to_string/db_extension.py +11 -5
- pylegend/core/{databse → database}/sql_to_string/generator.py +2 -2
- pylegend/core/language/__init__.py +10 -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} +3 -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 +164 -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/{operations → shared/operations}/primitive_operation_expressions.py +42 -3
- pylegend/core/language/{operations → shared/operations}/string_operation_expressions.py +169 -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 +23 -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 +25 -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 +8 -1
- pylegend/core/request/auth.py +89 -11
- pylegend/core/request/legend_client.py +32 -0
- pylegend/core/sql/metamodel_extension.py +16 -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.2.2.dist-info → pylegend-0.4.0.dist-info}/METADATA +7 -8
- pylegend-0.4.0.dist-info/NOTICE +5 -0
- pylegend-0.4.0.dist-info/RECORD +155 -0
- {pylegend-0.2.2.dist-info → pylegend-0.4.0.dist-info}/WHEEL +1 -1
- pylegend/core/tds/legend_api/frames/legend_api_base_tds_frame.py +0 -294
- pylegend-0.2.2.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.2.2.dist-info → pylegend-0.4.0.dist-info}/LICENSE +0 -0
- {pylegend-0.2.2.dist-info → pylegend-0.4.0.dist-info}/LICENSE.spdx +0 -0
pylegend/__init__.py
CHANGED
|
@@ -15,14 +15,16 @@
|
|
|
15
15
|
from pylegend._typing import (
|
|
16
16
|
PyLegendSequence,
|
|
17
17
|
)
|
|
18
|
-
from pylegend.
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
from pylegend.legacy_api_tds_client import (
|
|
19
|
+
LegacyApiTdsClient,
|
|
20
|
+
legacy_api_tds_client,
|
|
21
21
|
)
|
|
22
22
|
from pylegend.core.request import (
|
|
23
23
|
LegendClient,
|
|
24
24
|
AuthScheme,
|
|
25
25
|
LocalhostEmptyAuthScheme,
|
|
26
|
+
HeaderTokenAuthScheme,
|
|
27
|
+
CookieAuthScheme,
|
|
26
28
|
ResponseReader,
|
|
27
29
|
)
|
|
28
30
|
from pylegend.core.project_cooridnates import (
|
|
@@ -36,12 +38,14 @@ from pylegend.core.language import agg
|
|
|
36
38
|
__all__: PyLegendSequence[str] = [
|
|
37
39
|
"__version__",
|
|
38
40
|
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
+
"LegacyApiTdsClient",
|
|
42
|
+
"legacy_api_tds_client",
|
|
41
43
|
|
|
42
44
|
"LegendClient",
|
|
43
45
|
"AuthScheme",
|
|
44
46
|
"LocalhostEmptyAuthScheme",
|
|
47
|
+
"HeaderTokenAuthScheme",
|
|
48
|
+
"CookieAuthScheme",
|
|
45
49
|
"ResponseReader",
|
|
46
50
|
|
|
47
51
|
"VersionedProjectCoordinates",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
from pylegend._typing import PyLegendSequence
|
|
16
|
-
from pylegend.core.
|
|
17
|
-
from pylegend.core.
|
|
18
|
-
from pylegend.core.
|
|
16
|
+
from pylegend.core.database.sql_to_string.generator import SqlToStringGenerator
|
|
17
|
+
from pylegend.core.database.sql_to_string.config import SqlToStringConfig, SqlToStringFormat
|
|
18
|
+
from pylegend.core.database.sql_to_string.db_extension import SqlToStringDbExtension
|
|
19
19
|
|
|
20
20
|
__all__: PyLegendSequence[str] = [
|
|
21
21
|
"SqlToStringGenerator",
|
|
@@ -18,7 +18,7 @@ from pylegend._typing import (
|
|
|
18
18
|
PyLegendList,
|
|
19
19
|
PyLegendSequence
|
|
20
20
|
)
|
|
21
|
-
from pylegend.core.
|
|
21
|
+
from pylegend.core.database.sql_to_string.config import SqlToStringConfig
|
|
22
22
|
from pylegend.core.sql.metamodel import (
|
|
23
23
|
QuerySpecification,
|
|
24
24
|
Select,
|
|
@@ -130,6 +130,7 @@ from pylegend.core.sql.metamodel_extension import (
|
|
|
130
130
|
MinuteExpression,
|
|
131
131
|
SecondExpression,
|
|
132
132
|
EpochExpression,
|
|
133
|
+
WindowExpression,
|
|
133
134
|
)
|
|
134
135
|
|
|
135
136
|
|
|
@@ -448,6 +449,8 @@ def expression_processor(
|
|
|
448
449
|
return extension.process_second_expression(expression, config)
|
|
449
450
|
elif isinstance(expression, EpochExpression):
|
|
450
451
|
return extension.process_epoch_expression(expression, config)
|
|
452
|
+
elif isinstance(expression, WindowExpression):
|
|
453
|
+
return extension.process_window_expression(expression, config)
|
|
451
454
|
|
|
452
455
|
else:
|
|
453
456
|
raise ValueError("Unsupported expression type: " + str(type(expression))) # pragma: no cover
|
|
@@ -674,7 +677,7 @@ def function_call_processor(
|
|
|
674
677
|
|
|
675
678
|
window = ""
|
|
676
679
|
if function_call.window:
|
|
677
|
-
window = "
|
|
680
|
+
window = " " + extension.process_window(function_call.window, config)
|
|
678
681
|
|
|
679
682
|
first_sep = config.format.separator(1) if function_call.arguments else ""
|
|
680
683
|
sep0 = config.format.separator(0) if function_call.arguments else ""
|
|
@@ -838,14 +841,14 @@ def window_processor(
|
|
|
838
841
|
if window.windowRef:
|
|
839
842
|
return window.windowRef
|
|
840
843
|
|
|
841
|
-
partitions = "
|
|
844
|
+
partitions = "PARTITION BY " + (", ".join([extension.process_expression(e, config) for e in window.partitions])) \
|
|
842
845
|
if window.partitions else ""
|
|
843
846
|
|
|
844
|
-
order_by = "
|
|
847
|
+
order_by = "ORDER BY " + (", ".join([extension.process_sort_item(o, config) for o in window.orderBy])) \
|
|
845
848
|
if window.orderBy else ""
|
|
846
849
|
|
|
847
850
|
# TODO: Handle window frame
|
|
848
|
-
return f"{partitions}{order_by}{''}"
|
|
851
|
+
return f"OVER ({partitions}{' ' if (partitions != '') and (order_by != '') else ''}{order_by}){''}"
|
|
849
852
|
|
|
850
853
|
|
|
851
854
|
def table_function_processor(
|
|
@@ -1162,6 +1165,9 @@ class SqlToStringDbExtension:
|
|
|
1162
1165
|
def process_epoch_expression(self, expr: EpochExpression, config: SqlToStringConfig) -> str:
|
|
1163
1166
|
return f"DATE_PART('epoch', {self.process_expression(expr.value, config)})"
|
|
1164
1167
|
|
|
1168
|
+
def process_window_expression(self, expr: WindowExpression, config: SqlToStringConfig) -> str:
|
|
1169
|
+
return f"{self.process_expression(expr.nested, config)} {self.process_window(expr.window, config)}"
|
|
1170
|
+
|
|
1165
1171
|
def process_qualified_name(self, qualified_name: QualifiedName, config: SqlToStringConfig) -> str:
|
|
1166
1172
|
return qualified_name_processor(qualified_name, self, config)
|
|
1167
1173
|
|
|
@@ -18,8 +18,8 @@ from pylegend._typing import (
|
|
|
18
18
|
PyLegendDict
|
|
19
19
|
)
|
|
20
20
|
from pylegend.utils.class_utils import find_sub_classes
|
|
21
|
-
from pylegend.core.
|
|
22
|
-
from pylegend.core.
|
|
21
|
+
from pylegend.core.database.sql_to_string.config import SqlToStringConfig
|
|
22
|
+
from pylegend.core.database.sql_to_string.db_extension import SqlToStringDbExtension
|
|
23
23
|
from pylegend.core.sql.metamodel import QuerySpecification
|
|
24
24
|
|
|
25
25
|
__all__: PyLegendSequence[str] = [
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
from pylegend._typing import (
|
|
16
16
|
PyLegendSequence,
|
|
17
17
|
)
|
|
18
|
-
from pylegend.core.language.primitives import (
|
|
18
|
+
from pylegend.core.language.shared.primitives import (
|
|
19
19
|
PyLegendPrimitive,
|
|
20
20
|
PyLegendPrimitiveOrPythonPrimitive,
|
|
21
21
|
PyLegendBoolean,
|
|
@@ -27,7 +27,7 @@ from pylegend.core.language.primitives import (
|
|
|
27
27
|
PyLegendDateTime,
|
|
28
28
|
PyLegendStrictDate,
|
|
29
29
|
)
|
|
30
|
-
from pylegend.core.language.expression import (
|
|
30
|
+
from pylegend.core.language.shared.expression import (
|
|
31
31
|
PyLegendExpressionBooleanReturn,
|
|
32
32
|
PyLegendExpressionStringReturn,
|
|
33
33
|
PyLegendExpressionNumberReturn,
|
|
@@ -37,7 +37,7 @@ from pylegend.core.language.expression import (
|
|
|
37
37
|
PyLegendExpressionDateTimeReturn,
|
|
38
38
|
PyLegendExpressionStrictDateReturn,
|
|
39
39
|
)
|
|
40
|
-
from pylegend.core.language.literal_expressions import (
|
|
40
|
+
from pylegend.core.language.shared.literal_expressions import (
|
|
41
41
|
PyLegendBooleanLiteralExpression,
|
|
42
42
|
PyLegendStringLiteralExpression,
|
|
43
43
|
PyLegendIntegerLiteralExpression,
|
|
@@ -46,7 +46,7 @@ from pylegend.core.language.literal_expressions import (
|
|
|
46
46
|
PyLegendStrictDateLiteralExpression,
|
|
47
47
|
convert_literal_to_literal_expression,
|
|
48
48
|
)
|
|
49
|
-
from pylegend.core.language.column_expressions import (
|
|
49
|
+
from pylegend.core.language.shared.column_expressions import (
|
|
50
50
|
PyLegendColumnExpression,
|
|
51
51
|
PyLegendBooleanColumnExpression,
|
|
52
52
|
PyLegendStringColumnExpression,
|
|
@@ -57,9 +57,9 @@ from pylegend.core.language.column_expressions import (
|
|
|
57
57
|
PyLegendDateTimeColumnExpression,
|
|
58
58
|
PyLegendStrictDateColumnExpression,
|
|
59
59
|
)
|
|
60
|
-
from pylegend.core.language.
|
|
61
|
-
from pylegend.core.language.aggregate_specification import
|
|
62
|
-
from pylegend.core.language.primitive_collection import (
|
|
60
|
+
from pylegend.core.language.legacy_api.legacy_api_tds_row import LegacyApiTdsRow
|
|
61
|
+
from pylegend.core.language.legacy_api.aggregate_specification import LegacyApiAggregateSpecification, agg
|
|
62
|
+
from pylegend.core.language.shared.primitive_collection import (
|
|
63
63
|
PyLegendPrimitiveCollection,
|
|
64
64
|
PyLegendIntegerCollection,
|
|
65
65
|
PyLegendFloatCollection,
|
|
@@ -71,7 +71,7 @@ from pylegend.core.language.primitive_collection import (
|
|
|
71
71
|
PyLegendStrictDateCollection,
|
|
72
72
|
create_primitive_collection,
|
|
73
73
|
)
|
|
74
|
-
from pylegend.core.language.functions import (
|
|
74
|
+
from pylegend.core.language.shared.functions import (
|
|
75
75
|
today,
|
|
76
76
|
now,
|
|
77
77
|
)
|
|
@@ -115,8 +115,8 @@ __all__: PyLegendSequence[str] = [
|
|
|
115
115
|
"PyLegendStrictDateLiteralExpression",
|
|
116
116
|
"convert_literal_to_literal_expression",
|
|
117
117
|
|
|
118
|
-
"
|
|
119
|
-
"
|
|
118
|
+
"LegacyApiTdsRow",
|
|
119
|
+
"LegacyApiAggregateSpecification",
|
|
120
120
|
"agg",
|
|
121
121
|
|
|
122
122
|
"PyLegendPrimitiveCollection",
|
|
@@ -0,0 +1,13 @@
|
|
|
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.
|
|
@@ -16,27 +16,27 @@ from pylegend._typing import (
|
|
|
16
16
|
PyLegendSequence,
|
|
17
17
|
PyLegendCallable
|
|
18
18
|
)
|
|
19
|
-
from pylegend.core.language.primitive_collection import PyLegendPrimitiveCollection
|
|
19
|
+
from pylegend.core.language.shared.primitive_collection import PyLegendPrimitiveCollection
|
|
20
20
|
from pylegend.core.language import (
|
|
21
|
-
|
|
21
|
+
LegacyApiTdsRow,
|
|
22
22
|
PyLegendPrimitive,
|
|
23
23
|
PyLegendPrimitiveOrPythonPrimitive,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
__all__: PyLegendSequence[str] = [
|
|
27
|
-
"
|
|
27
|
+
"LegacyApiAggregateSpecification",
|
|
28
28
|
"agg",
|
|
29
29
|
]
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
class
|
|
33
|
-
__map_fn: PyLegendCallable[[
|
|
32
|
+
class LegacyApiAggregateSpecification:
|
|
33
|
+
__map_fn: PyLegendCallable[[LegacyApiTdsRow], PyLegendPrimitiveOrPythonPrimitive]
|
|
34
34
|
__aggregate_fn: PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive]
|
|
35
35
|
__name: str
|
|
36
36
|
|
|
37
37
|
def __init__(
|
|
38
38
|
self,
|
|
39
|
-
map_fn: PyLegendCallable[[
|
|
39
|
+
map_fn: PyLegendCallable[[LegacyApiTdsRow], PyLegendPrimitiveOrPythonPrimitive],
|
|
40
40
|
aggregate_fn: PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive],
|
|
41
41
|
name: str
|
|
42
42
|
) -> None:
|
|
@@ -47,7 +47,7 @@ class AggregateSpecification:
|
|
|
47
47
|
def get_name(self) -> str:
|
|
48
48
|
return self.__name
|
|
49
49
|
|
|
50
|
-
def get_map_fn(self) -> PyLegendCallable[[
|
|
50
|
+
def get_map_fn(self) -> PyLegendCallable[[LegacyApiTdsRow], PyLegendPrimitiveOrPythonPrimitive]:
|
|
51
51
|
return self.__map_fn
|
|
52
52
|
|
|
53
53
|
def get_aggregate_fn(self) -> PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive]:
|
|
@@ -55,8 +55,8 @@ class AggregateSpecification:
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
def agg(
|
|
58
|
-
map_fn: PyLegendCallable[[
|
|
58
|
+
map_fn: PyLegendCallable[[LegacyApiTdsRow], PyLegendPrimitiveOrPythonPrimitive],
|
|
59
59
|
aggregate_fn: PyLegendCallable[[PyLegendPrimitiveCollection], PyLegendPrimitive],
|
|
60
60
|
name: str
|
|
61
|
-
) ->
|
|
62
|
-
return
|
|
61
|
+
) -> LegacyApiAggregateSpecification:
|
|
62
|
+
return LegacyApiAggregateSpecification(map_fn=map_fn, aggregate_fn=aggregate_fn, name=name)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Copyright 2023 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 pylegend._typing import (
|
|
16
|
+
PyLegendSequence,
|
|
17
|
+
)
|
|
18
|
+
from pylegend.core.language.shared.tds_row import AbstractTdsRow
|
|
19
|
+
from pylegend.core.tds.tds_frame import PyLegendTdsFrame
|
|
20
|
+
|
|
21
|
+
__all__: PyLegendSequence[str] = [
|
|
22
|
+
"LegacyApiTdsRow",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class LegacyApiTdsRow(AbstractTdsRow):
|
|
27
|
+
def __init__(self, frame_name: str, frame: PyLegendTdsFrame) -> None:
|
|
28
|
+
super().__init__(frame_name, frame)
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def from_tds_frame(frame_name: str, frame: PyLegendTdsFrame) -> "LegacyApiTdsRow":
|
|
32
|
+
return LegacyApiTdsRow(frame_name=frame_name, frame=frame)
|
|
@@ -0,0 +1,13 @@
|
|
|
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.
|