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.
Files changed (123) hide show
  1. pylegend/__init__.py +9 -5
  2. pylegend/core/{databse → database}/sql_to_string/__init__.py +3 -3
  3. pylegend/core/{databse → database}/sql_to_string/db_extension.py +11 -5
  4. pylegend/core/{databse → database}/sql_to_string/generator.py +2 -2
  5. pylegend/core/language/__init__.py +10 -10
  6. pylegend/core/language/legacy_api/__init__.py +13 -0
  7. pylegend/core/language/{aggregate_specification.py → legacy_api/aggregate_specification.py} +10 -10
  8. pylegend/core/language/legacy_api/legacy_api_tds_row.py +32 -0
  9. pylegend/core/language/legendql_api/__init__.py +13 -0
  10. pylegend/core/language/legendql_api/legendql_api_custom_expressions.py +541 -0
  11. pylegend/core/language/legendql_api/legendql_api_tds_row.py +292 -0
  12. pylegend/core/language/shared/__init__.py +13 -0
  13. pylegend/core/language/{column_expressions.py → shared/column_expressions.py} +32 -31
  14. pylegend/core/language/{expression.py → shared/expression.py} +8 -0
  15. pylegend/core/language/{functions.py → shared/functions.py} +3 -3
  16. pylegend/core/language/shared/helpers.py +75 -0
  17. pylegend/core/language/{literal_expressions.py → shared/literal_expressions.py} +39 -1
  18. pylegend/core/language/{operations → shared/operations}/binary_expression.py +34 -2
  19. pylegend/core/language/{operations → shared/operations}/boolean_operation_expressions.py +34 -6
  20. pylegend/core/language/{operations → shared/operations}/collection_operation_expressions.py +146 -26
  21. pylegend/core/language/{operations → shared/operations}/date_operation_expressions.py +164 -24
  22. pylegend/core/language/{operations → shared/operations}/float_operation_expressions.py +53 -8
  23. pylegend/core/language/{operations → shared/operations}/integer_operation_expressions.py +62 -9
  24. pylegend/core/language/{operations → shared/operations}/nullary_expression.py +9 -2
  25. pylegend/core/language/{operations → shared/operations}/number_operation_expressions.py +211 -30
  26. pylegend/core/language/{operations → shared/operations}/primitive_operation_expressions.py +42 -3
  27. pylegend/core/language/{operations → shared/operations}/string_operation_expressions.py +169 -21
  28. pylegend/core/language/{operations → shared/operations}/unary_expression.py +10 -2
  29. pylegend/core/language/{primitive_collection.py → shared/primitive_collection.py} +2 -2
  30. pylegend/core/language/{primitives → shared/primitives}/__init__.py +9 -9
  31. pylegend/core/language/{primitives → shared/primitives}/boolean.py +9 -5
  32. pylegend/core/language/{primitives → shared/primitives}/date.py +23 -15
  33. pylegend/core/language/{primitives → shared/primitives}/datetime.py +4 -5
  34. pylegend/core/language/{primitives → shared/primitives}/float.py +6 -6
  35. pylegend/core/language/{primitives → shared/primitives}/integer.py +6 -6
  36. pylegend/core/language/{primitives → shared/primitives}/number.py +16 -13
  37. pylegend/core/language/{primitives → shared/primitives}/primitive.py +25 -5
  38. pylegend/core/language/{primitives → shared/primitives}/strictdate.py +4 -5
  39. pylegend/core/language/{primitives → shared/primitives}/string.py +18 -19
  40. pylegend/core/language/{tds_row.py → shared/tds_row.py} +46 -16
  41. pylegend/core/request/__init__.py +8 -1
  42. pylegend/core/request/auth.py +89 -11
  43. pylegend/core/request/legend_client.py +32 -0
  44. pylegend/core/sql/metamodel_extension.py +16 -0
  45. pylegend/core/tds/abstract/__init__.py +13 -0
  46. pylegend/core/tds/abstract/frames/__init__.py +13 -0
  47. pylegend/core/tds/{legend_api/frames/legend_api_applied_function_tds_frame.py → abstract/frames/applied_function_tds_frame.py} +19 -13
  48. pylegend/core/tds/abstract/frames/base_tds_frame.py +125 -0
  49. pylegend/core/tds/{legend_api/frames/legend_api_input_tds_frame.py → abstract/frames/input_tds_frame.py} +9 -12
  50. pylegend/core/tds/{legend_api/frames/functions → abstract}/function_helpers.py +1 -1
  51. pylegend/core/tds/{legend_api/frames/functions/concatenate_function.py → legacy_api/frames/functions/legacy_api_concatenate_function.py} +25 -13
  52. pylegend/core/tds/{legend_api/frames/functions/distinct_function.py → legacy_api/frames/functions/legacy_api_distinct_function.py} +13 -8
  53. pylegend/core/tds/{legend_api/frames/functions/drop_function.py → legacy_api/frames/functions/legacy_api_drop_function.py} +13 -8
  54. pylegend/core/tds/{legend_api/frames/functions/extend_function.py → legacy_api/frames/functions/legacy_api_extend_function.py} +36 -16
  55. pylegend/core/tds/{legend_api/frames/functions/filter_function.py → legacy_api/frames/functions/legacy_api_filter_function.py} +25 -13
  56. pylegend/core/tds/{legend_api/frames/functions/group_by_function.py → legacy_api/frames/functions/legacy_api_group_by_function.py} +44 -17
  57. pylegend/core/tds/{legend_api/frames/functions/head_function.py → legacy_api/frames/functions/legacy_api_head_function.py} +13 -8
  58. 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
  59. pylegend/core/tds/{legend_api/frames/functions/join_function.py → legacy_api/frames/functions/legacy_api_join_function.py} +44 -20
  60. pylegend/core/tds/{legend_api/frames/functions/rename_columns_function.py → legacy_api/frames/functions/legacy_api_rename_columns_function.py} +20 -8
  61. pylegend/core/tds/{legend_api/frames/functions/restrict_function.py → legacy_api/frames/functions/legacy_api_restrict_function.py} +17 -8
  62. pylegend/core/tds/{legend_api/frames/functions/slice_function.py → legacy_api/frames/functions/legacy_api_slice_function.py} +13 -8
  63. pylegend/core/tds/{legend_api/frames/functions/sort_function.py → legacy_api/frames/functions/legacy_api_sort_function.py} +19 -8
  64. pylegend/core/tds/legacy_api/frames/legacy_api_applied_function_tds_frame.py +37 -0
  65. pylegend/core/tds/legacy_api/frames/legacy_api_base_tds_frame.py +204 -0
  66. pylegend/core/tds/legacy_api/frames/legacy_api_input_tds_frame.py +51 -0
  67. pylegend/core/tds/{legend_api/frames/legend_api_tds_frame.py → legacy_api/frames/legacy_api_tds_frame.py} +28 -28
  68. pylegend/core/tds/legendql_api/__init__.py +13 -0
  69. pylegend/core/tds/legendql_api/frames/__init__.py +13 -0
  70. pylegend/core/tds/legendql_api/frames/functions/__init__.py +13 -0
  71. pylegend/core/tds/legendql_api/frames/functions/legendql_api_asofjoin_function.py +156 -0
  72. pylegend/core/tds/legendql_api/frames/functions/legendql_api_concatenate_function.py +139 -0
  73. pylegend/core/tds/legendql_api/frames/functions/legendql_api_distinct_function.py +69 -0
  74. pylegend/core/tds/legendql_api/frames/functions/legendql_api_drop_function.py +74 -0
  75. pylegend/core/tds/legendql_api/frames/functions/legendql_api_extend_function.py +256 -0
  76. pylegend/core/tds/legendql_api/frames/functions/legendql_api_filter_function.py +121 -0
  77. pylegend/core/tds/legendql_api/frames/functions/legendql_api_function_helpers.py +137 -0
  78. pylegend/core/tds/legendql_api/frames/functions/legendql_api_groupby_function.py +256 -0
  79. pylegend/core/tds/legendql_api/frames/functions/legendql_api_head_function.py +74 -0
  80. pylegend/core/tds/legendql_api/frames/functions/legendql_api_join_function.py +214 -0
  81. pylegend/core/tds/legendql_api/frames/functions/legendql_api_project_function.py +169 -0
  82. pylegend/core/tds/legendql_api/frames/functions/legendql_api_rename_function.py +189 -0
  83. pylegend/core/tds/legendql_api/frames/functions/legendql_api_select_function.py +131 -0
  84. pylegend/core/tds/legendql_api/frames/functions/legendql_api_slice_function.py +82 -0
  85. pylegend/core/tds/legendql_api/frames/functions/legendql_api_sort_function.py +93 -0
  86. pylegend/core/tds/legendql_api/frames/functions/legendql_api_window_extend_function.py +283 -0
  87. pylegend/core/tds/legendql_api/frames/legendql_api_applied_function_tds_frame.py +37 -0
  88. pylegend/core/tds/legendql_api/frames/legendql_api_base_tds_frame.py +419 -0
  89. pylegend/core/tds/legendql_api/frames/legendql_api_input_tds_frame.py +50 -0
  90. pylegend/core/tds/legendql_api/frames/legendql_api_tds_frame.py +327 -0
  91. pylegend/core/tds/pandas_api/frames/functions/assign_function.py +6 -6
  92. pylegend/core/tds/pandas_api/frames/pandas_api_applied_function_tds_frame.py +4 -0
  93. pylegend/core/tds/pandas_api/frames/pandas_api_base_tds_frame.py +11 -3
  94. pylegend/core/tds/pandas_api/frames/pandas_api_tds_frame.py +2 -2
  95. pylegend/core/tds/tds_frame.py +32 -2
  96. pylegend/extensions/database/vendors/postgres/postgres_sql_to_string.py +1 -1
  97. pylegend/extensions/tds/abstract/legend_function_input_frame.py +4 -0
  98. pylegend/extensions/tds/abstract/legend_service_input_frame.py +4 -0
  99. pylegend/extensions/tds/abstract/table_spec_input_frame.py +4 -0
  100. 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
  101. 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
  102. 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
  103. pylegend/extensions/tds/legendql_api/__init__.py +13 -0
  104. pylegend/extensions/tds/legendql_api/frames/__init__.py +13 -0
  105. pylegend/extensions/tds/legendql_api/frames/legendql_api_legend_service_input_frame.py +46 -0
  106. pylegend/extensions/tds/legendql_api/frames/legendql_api_table_spec_input_frame.py +36 -0
  107. pylegend/{legend_api_tds_client.py → legacy_api_tds_client.py} +15 -15
  108. {pylegend-0.2.2.dist-info → pylegend-0.4.0.dist-info}/METADATA +7 -8
  109. pylegend-0.4.0.dist-info/NOTICE +5 -0
  110. pylegend-0.4.0.dist-info/RECORD +155 -0
  111. {pylegend-0.2.2.dist-info → pylegend-0.4.0.dist-info}/WHEEL +1 -1
  112. pylegend/core/tds/legend_api/frames/legend_api_base_tds_frame.py +0 -294
  113. pylegend-0.2.2.dist-info/RECORD +0 -115
  114. /pylegend/core/{databse → database}/__init__.py +0 -0
  115. /pylegend/core/{databse → database}/sql_to_string/config.py +0 -0
  116. /pylegend/core/language/{operations → shared/operations}/__init__.py +0 -0
  117. /pylegend/core/tds/{legend_api → legacy_api}/__init__.py +0 -0
  118. /pylegend/core/tds/{legend_api → legacy_api}/frames/__init__.py +0 -0
  119. /pylegend/core/tds/{legend_api → legacy_api}/frames/functions/__init__.py +0 -0
  120. /pylegend/extensions/tds/{legend_api → legacy_api}/__init__.py +0 -0
  121. /pylegend/extensions/tds/{legend_api → legacy_api}/frames/__init__.py +0 -0
  122. {pylegend-0.2.2.dist-info → pylegend-0.4.0.dist-info}/LICENSE +0 -0
  123. {pylegend-0.2.2.dist-info → pylegend-0.4.0.dist-info}/LICENSE.spdx +0 -0
@@ -16,14 +16,16 @@ from pylegend._typing import (
16
16
  PyLegendSequence,
17
17
  PyLegendDict,
18
18
  )
19
- from pylegend.core.language.expression import (
19
+ from pylegend.core.language.shared.expression import (
20
20
  PyLegendExpressionNumberReturn,
21
21
  PyLegendExpressionIntegerReturn,
22
22
  PyLegendExpressionBooleanReturn,
23
23
  )
24
- from pylegend.core.language.operations.binary_expression import PyLegendBinaryExpression
25
- from pylegend.core.language.operations.unary_expression import PyLegendUnaryExpression
24
+ from pylegend.core.language.shared.operations.binary_expression import PyLegendBinaryExpression
25
+ from pylegend.core.language.shared.operations.unary_expression import PyLegendUnaryExpression
26
+ from pylegend.core.language.shared.helpers import generate_pure_functional_call
26
27
  from pylegend.core.tds.tds_frame import FrameToSqlConfig
28
+ from pylegend.core.tds.tds_frame import FrameToPureConfig
27
29
  from pylegend.core.sql.metamodel import (
28
30
  Expression,
29
31
  QuerySpecification,
@@ -97,15 +99,26 @@ class PyLegendNumberAddExpression(PyLegendBinaryExpression, PyLegendExpressionNu
97
99
  ) -> Expression:
98
100
  return ArithmeticExpression(ArithmeticType.ADD, expression1, expression2)
99
101
 
102
+ @staticmethod
103
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
104
+ return f"({op1_expr} + {op2_expr})"
105
+
100
106
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
101
107
  PyLegendExpressionNumberReturn.__init__(self)
102
108
  PyLegendBinaryExpression.__init__(
103
109
  self,
104
110
  operand1,
105
111
  operand2,
106
- PyLegendNumberAddExpression.__to_sql_func
112
+ PyLegendNumberAddExpression.__to_sql_func,
113
+ PyLegendNumberAddExpression.__to_pure_func
107
114
  )
108
115
 
116
+ def is_non_nullable(self) -> bool:
117
+ return True
118
+
119
+ def to_pure_expression(self, config: FrameToPureConfig) -> str:
120
+ return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
121
+
109
122
 
110
123
  class PyLegendNumberMultiplyExpression(PyLegendBinaryExpression, PyLegendExpressionNumberReturn):
111
124
 
@@ -118,15 +131,26 @@ class PyLegendNumberMultiplyExpression(PyLegendBinaryExpression, PyLegendExpress
118
131
  ) -> Expression:
119
132
  return ArithmeticExpression(ArithmeticType.MULTIPLY, expression1, expression2)
120
133
 
134
+ @staticmethod
135
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
136
+ return f"({op1_expr} * {op2_expr})"
137
+
121
138
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
122
139
  PyLegendExpressionNumberReturn.__init__(self)
123
140
  PyLegendBinaryExpression.__init__(
124
141
  self,
125
142
  operand1,
126
143
  operand2,
127
- PyLegendNumberMultiplyExpression.__to_sql_func
144
+ PyLegendNumberMultiplyExpression.__to_sql_func,
145
+ PyLegendNumberMultiplyExpression.__to_pure_func
128
146
  )
129
147
 
148
+ def is_non_nullable(self) -> bool:
149
+ return True
150
+
151
+ def to_pure_expression(self, config: FrameToPureConfig) -> str:
152
+ return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
153
+
130
154
 
131
155
  class PyLegendNumberDivideExpression(PyLegendBinaryExpression, PyLegendExpressionNumberReturn):
132
156
 
@@ -139,15 +163,23 @@ class PyLegendNumberDivideExpression(PyLegendBinaryExpression, PyLegendExpressio
139
163
  ) -> Expression:
140
164
  return ArithmeticExpression(ArithmeticType.DIVIDE, expression1, expression2)
141
165
 
166
+ @staticmethod
167
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
168
+ return f"{op1_expr}->map(op | $op / {op2_expr})"
169
+
142
170
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
143
171
  PyLegendExpressionNumberReturn.__init__(self)
144
172
  PyLegendBinaryExpression.__init__(
145
173
  self,
146
174
  operand1,
147
175
  operand2,
148
- PyLegendNumberDivideExpression.__to_sql_func
176
+ PyLegendNumberDivideExpression.__to_sql_func,
177
+ PyLegendNumberDivideExpression.__to_pure_func
149
178
  )
150
179
 
180
+ def to_pure_expression(self, config: FrameToPureConfig) -> str:
181
+ return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_second_operand(self, config)
182
+
151
183
 
152
184
  class PyLegendNumberSubtractExpression(PyLegendBinaryExpression, PyLegendExpressionNumberReturn):
153
185
 
@@ -160,15 +192,26 @@ class PyLegendNumberSubtractExpression(PyLegendBinaryExpression, PyLegendExpress
160
192
  ) -> Expression:
161
193
  return ArithmeticExpression(ArithmeticType.SUBTRACT, expression1, expression2)
162
194
 
195
+ @staticmethod
196
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
197
+ return f"({op1_expr} - {op2_expr})"
198
+
163
199
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
164
200
  PyLegendExpressionNumberReturn.__init__(self)
165
201
  PyLegendBinaryExpression.__init__(
166
202
  self,
167
203
  operand1,
168
204
  operand2,
169
- PyLegendNumberSubtractExpression.__to_sql_func
205
+ PyLegendNumberSubtractExpression.__to_sql_func,
206
+ PyLegendNumberSubtractExpression.__to_pure_func
170
207
  )
171
208
 
209
+ def is_non_nullable(self) -> bool:
210
+ return True
211
+
212
+ def to_pure_expression(self, config: FrameToPureConfig) -> str:
213
+ return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
214
+
172
215
 
173
216
  class PyLegendNumberLessThanExpression(PyLegendBinaryExpression, PyLegendExpressionBooleanReturn):
174
217
 
@@ -181,15 +224,23 @@ class PyLegendNumberLessThanExpression(PyLegendBinaryExpression, PyLegendExpress
181
224
  ) -> Expression:
182
225
  return ComparisonExpression(expression1, expression2, ComparisonOperator.LESS_THAN)
183
226
 
227
+ @staticmethod
228
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
229
+ return f"({op1_expr} < {op2_expr})"
230
+
184
231
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
185
232
  PyLegendExpressionBooleanReturn.__init__(self)
186
233
  PyLegendBinaryExpression.__init__(
187
234
  self,
188
235
  operand1,
189
236
  operand2,
190
- PyLegendNumberLessThanExpression.__to_sql_func
237
+ PyLegendNumberLessThanExpression.__to_sql_func,
238
+ PyLegendNumberLessThanExpression.__to_pure_func
191
239
  )
192
240
 
241
+ def is_non_nullable(self) -> bool:
242
+ return True
243
+
193
244
 
194
245
  class PyLegendNumberLessThanEqualExpression(PyLegendBinaryExpression, PyLegendExpressionBooleanReturn):
195
246
 
@@ -202,15 +253,23 @@ class PyLegendNumberLessThanEqualExpression(PyLegendBinaryExpression, PyLegendEx
202
253
  ) -> Expression:
203
254
  return ComparisonExpression(expression1, expression2, ComparisonOperator.LESS_THAN_OR_EQUAL)
204
255
 
256
+ @staticmethod
257
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
258
+ return f"({op1_expr} <= {op2_expr})"
259
+
205
260
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
206
261
  PyLegendExpressionBooleanReturn.__init__(self)
207
262
  PyLegendBinaryExpression.__init__(
208
263
  self,
209
264
  operand1,
210
265
  operand2,
211
- PyLegendNumberLessThanEqualExpression.__to_sql_func
266
+ PyLegendNumberLessThanEqualExpression.__to_sql_func,
267
+ PyLegendNumberLessThanEqualExpression.__to_pure_func
212
268
  )
213
269
 
270
+ def is_non_nullable(self) -> bool:
271
+ return True
272
+
214
273
 
215
274
  class PyLegendNumberGreaterThanExpression(PyLegendBinaryExpression, PyLegendExpressionBooleanReturn):
216
275
 
@@ -223,15 +282,23 @@ class PyLegendNumberGreaterThanExpression(PyLegendBinaryExpression, PyLegendExpr
223
282
  ) -> Expression:
224
283
  return ComparisonExpression(expression1, expression2, ComparisonOperator.GREATER_THAN)
225
284
 
285
+ @staticmethod
286
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
287
+ return f"({op1_expr} > {op2_expr})"
288
+
226
289
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
227
290
  PyLegendExpressionBooleanReturn.__init__(self)
228
291
  PyLegendBinaryExpression.__init__(
229
292
  self,
230
293
  operand1,
231
294
  operand2,
232
- PyLegendNumberGreaterThanExpression.__to_sql_func
295
+ PyLegendNumberGreaterThanExpression.__to_sql_func,
296
+ PyLegendNumberGreaterThanExpression.__to_pure_func
233
297
  )
234
298
 
299
+ def is_non_nullable(self) -> bool:
300
+ return True
301
+
235
302
 
236
303
  class PyLegendNumberGreaterThanEqualExpression(PyLegendBinaryExpression, PyLegendExpressionBooleanReturn):
237
304
 
@@ -244,15 +311,23 @@ class PyLegendNumberGreaterThanEqualExpression(PyLegendBinaryExpression, PyLegen
244
311
  ) -> Expression:
245
312
  return ComparisonExpression(expression1, expression2, ComparisonOperator.GREATER_THAN_OR_EQUAL)
246
313
 
314
+ @staticmethod
315
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
316
+ return f"({op1_expr} >= {op2_expr})"
317
+
247
318
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
248
319
  PyLegendExpressionBooleanReturn.__init__(self)
249
320
  PyLegendBinaryExpression.__init__(
250
321
  self,
251
322
  operand1,
252
323
  operand2,
253
- PyLegendNumberGreaterThanEqualExpression.__to_sql_func
324
+ PyLegendNumberGreaterThanEqualExpression.__to_sql_func,
325
+ PyLegendNumberGreaterThanEqualExpression.__to_pure_func
254
326
  )
255
327
 
328
+ def is_non_nullable(self) -> bool:
329
+ return True
330
+
256
331
 
257
332
  class PyLegendNumberNegativeExpression(PyLegendUnaryExpression, PyLegendExpressionNumberReturn):
258
333
 
@@ -264,12 +339,17 @@ class PyLegendNumberNegativeExpression(PyLegendUnaryExpression, PyLegendExpressi
264
339
  ) -> Expression:
265
340
  return NegativeExpression(expression)
266
341
 
342
+ @staticmethod
343
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
344
+ return generate_pure_functional_call("minus", [op_expr], auto_map=True)
345
+
267
346
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
268
347
  PyLegendExpressionNumberReturn.__init__(self)
269
348
  PyLegendUnaryExpression.__init__(
270
349
  self,
271
350
  operand,
272
- PyLegendNumberNegativeExpression.__to_sql_func
351
+ PyLegendNumberNegativeExpression.__to_sql_func,
352
+ PyLegendNumberNegativeExpression.__to_pure_func
273
353
  )
274
354
 
275
355
 
@@ -283,12 +363,17 @@ class PyLegendNumberAbsoluteExpression(PyLegendUnaryExpression, PyLegendExpressi
283
363
  ) -> Expression:
284
364
  return AbsoluteExpression(expression)
285
365
 
366
+ @staticmethod
367
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
368
+ return generate_pure_functional_call("abs", [op_expr], auto_map=True)
369
+
286
370
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
287
371
  PyLegendExpressionNumberReturn.__init__(self)
288
372
  PyLegendUnaryExpression.__init__(
289
373
  self,
290
374
  operand,
291
- PyLegendNumberAbsoluteExpression.__to_sql_func
375
+ PyLegendNumberAbsoluteExpression.__to_sql_func,
376
+ PyLegendNumberAbsoluteExpression.__to_pure_func
292
377
  )
293
378
 
294
379
 
@@ -303,15 +388,23 @@ class PyLegendNumberPowerExpression(PyLegendBinaryExpression, PyLegendExpression
303
388
  ) -> Expression:
304
389
  return PowerExpression(expression1, expression2)
305
390
 
391
+ @staticmethod
392
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
393
+ return generate_pure_functional_call("pow", [op1_expr, op2_expr], auto_map=True)
394
+
306
395
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
307
396
  PyLegendExpressionNumberReturn.__init__(self)
308
397
  PyLegendBinaryExpression.__init__(
309
398
  self,
310
399
  operand1,
311
400
  operand2,
312
- PyLegendNumberPowerExpression.__to_sql_func
401
+ PyLegendNumberPowerExpression.__to_sql_func,
402
+ PyLegendNumberPowerExpression.__to_pure_func
313
403
  )
314
404
 
405
+ def to_pure_expression(self, config: FrameToPureConfig) -> str:
406
+ return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_second_operand(self, config)
407
+
315
408
 
316
409
  class PyLegendNumberCeilExpression(PyLegendUnaryExpression, PyLegendExpressionIntegerReturn):
317
410
 
@@ -323,12 +416,17 @@ class PyLegendNumberCeilExpression(PyLegendUnaryExpression, PyLegendExpressionIn
323
416
  ) -> Expression:
324
417
  return CeilExpression(expression)
325
418
 
419
+ @staticmethod
420
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
421
+ return generate_pure_functional_call("ceiling", [op_expr], auto_map=True)
422
+
326
423
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
327
424
  PyLegendExpressionIntegerReturn.__init__(self)
328
425
  PyLegendUnaryExpression.__init__(
329
426
  self,
330
427
  operand,
331
- PyLegendNumberCeilExpression.__to_sql_func
428
+ PyLegendNumberCeilExpression.__to_sql_func,
429
+ PyLegendNumberCeilExpression.__to_pure_func
332
430
  )
333
431
 
334
432
 
@@ -342,12 +440,17 @@ class PyLegendNumberFloorExpression(PyLegendUnaryExpression, PyLegendExpressionI
342
440
  ) -> Expression:
343
441
  return FloorExpression(expression)
344
442
 
443
+ @staticmethod
444
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
445
+ return generate_pure_functional_call("floor", [op_expr], auto_map=True)
446
+
345
447
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
346
448
  PyLegendExpressionIntegerReturn.__init__(self)
347
449
  PyLegendUnaryExpression.__init__(
348
450
  self,
349
451
  operand,
350
- PyLegendNumberFloorExpression.__to_sql_func
452
+ PyLegendNumberFloorExpression.__to_sql_func,
453
+ PyLegendNumberFloorExpression.__to_pure_func
351
454
  )
352
455
 
353
456
 
@@ -361,12 +464,17 @@ class PyLegendNumberSqrtExpression(PyLegendUnaryExpression, PyLegendExpressionNu
361
464
  ) -> Expression:
362
465
  return SqrtExpression(expression)
363
466
 
467
+ @staticmethod
468
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
469
+ return generate_pure_functional_call("sqrt", [op_expr], auto_map=True)
470
+
364
471
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
365
472
  PyLegendExpressionNumberReturn.__init__(self)
366
473
  PyLegendUnaryExpression.__init__(
367
474
  self,
368
475
  operand,
369
- PyLegendNumberSqrtExpression.__to_sql_func
476
+ PyLegendNumberSqrtExpression.__to_sql_func,
477
+ PyLegendNumberSqrtExpression.__to_pure_func
370
478
  )
371
479
 
372
480
 
@@ -380,12 +488,17 @@ class PyLegendNumberCbrtExpression(PyLegendUnaryExpression, PyLegendExpressionNu
380
488
  ) -> Expression:
381
489
  return CbrtExpression(expression)
382
490
 
491
+ @staticmethod
492
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
493
+ return generate_pure_functional_call("cbrt", [op_expr], auto_map=True)
494
+
383
495
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
384
496
  PyLegendExpressionNumberReturn.__init__(self)
385
497
  PyLegendUnaryExpression.__init__(
386
498
  self,
387
499
  operand,
388
- PyLegendNumberCbrtExpression.__to_sql_func
500
+ PyLegendNumberCbrtExpression.__to_sql_func,
501
+ PyLegendNumberCbrtExpression.__to_pure_func
389
502
  )
390
503
 
391
504
 
@@ -399,12 +512,17 @@ class PyLegendNumberExpExpression(PyLegendUnaryExpression, PyLegendExpressionNum
399
512
  ) -> Expression:
400
513
  return ExpExpression(expression)
401
514
 
515
+ @staticmethod
516
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
517
+ return generate_pure_functional_call("exp", [op_expr], auto_map=True)
518
+
402
519
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
403
520
  PyLegendExpressionNumberReturn.__init__(self)
404
521
  PyLegendUnaryExpression.__init__(
405
522
  self,
406
523
  operand,
407
- PyLegendNumberExpExpression.__to_sql_func
524
+ PyLegendNumberExpExpression.__to_sql_func,
525
+ PyLegendNumberExpExpression.__to_pure_func
408
526
  )
409
527
 
410
528
 
@@ -418,12 +536,17 @@ class PyLegendNumberLogExpression(PyLegendUnaryExpression, PyLegendExpressionNum
418
536
  ) -> Expression:
419
537
  return LogExpression(expression)
420
538
 
539
+ @staticmethod
540
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
541
+ return generate_pure_functional_call("log", [op_expr], auto_map=True)
542
+
421
543
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
422
544
  PyLegendExpressionNumberReturn.__init__(self)
423
545
  PyLegendUnaryExpression.__init__(
424
546
  self,
425
547
  operand,
426
- PyLegendNumberLogExpression.__to_sql_func
548
+ PyLegendNumberLogExpression.__to_sql_func,
549
+ PyLegendNumberLogExpression.__to_pure_func
427
550
  )
428
551
 
429
552
 
@@ -438,15 +561,23 @@ class PyLegendNumberRemainderExpression(PyLegendBinaryExpression, PyLegendExpres
438
561
  ) -> Expression:
439
562
  return RemainderExpression(expression1, expression2)
440
563
 
564
+ @staticmethod
565
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
566
+ return generate_pure_functional_call("rem", [op1_expr, op2_expr], auto_map=True)
567
+
441
568
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
442
569
  PyLegendExpressionNumberReturn.__init__(self)
443
570
  PyLegendBinaryExpression.__init__(
444
571
  self,
445
572
  operand1,
446
573
  operand2,
447
- PyLegendNumberRemainderExpression.__to_sql_func
574
+ PyLegendNumberRemainderExpression.__to_sql_func,
575
+ PyLegendNumberRemainderExpression.__to_pure_func
448
576
  )
449
577
 
578
+ def to_pure_expression(self, config: FrameToPureConfig) -> str:
579
+ return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_second_operand(self, config)
580
+
450
581
 
451
582
  class PyLegendNumberRoundExpression(PyLegendBinaryExpression, PyLegendExpressionNumberReturn):
452
583
 
@@ -459,13 +590,20 @@ class PyLegendNumberRoundExpression(PyLegendBinaryExpression, PyLegendExpression
459
590
  ) -> Expression:
460
591
  return RoundExpression(expression1, expression2)
461
592
 
593
+ @staticmethod
594
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
595
+ if op2_expr == "0":
596
+ return generate_pure_functional_call("round", [op1_expr], auto_map=True)
597
+ return generate_pure_functional_call("round", [f"cast({op1_expr}, @Float)", op2_expr], auto_map=True)
598
+
462
599
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionIntegerReturn) -> None:
463
600
  PyLegendExpressionNumberReturn.__init__(self)
464
601
  PyLegendBinaryExpression.__init__(
465
602
  self,
466
603
  operand1,
467
604
  operand2,
468
- PyLegendNumberRoundExpression.__to_sql_func
605
+ PyLegendNumberRoundExpression.__to_sql_func,
606
+ PyLegendNumberRoundExpression.__to_pure_func
469
607
  )
470
608
 
471
609
 
@@ -479,12 +617,17 @@ class PyLegendNumberSineExpression(PyLegendUnaryExpression, PyLegendExpressionNu
479
617
  ) -> Expression:
480
618
  return SineExpression(expression)
481
619
 
620
+ @staticmethod
621
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
622
+ return generate_pure_functional_call("sin", [op_expr], auto_map=True)
623
+
482
624
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
483
625
  PyLegendExpressionNumberReturn.__init__(self)
484
626
  PyLegendUnaryExpression.__init__(
485
627
  self,
486
628
  operand,
487
- PyLegendNumberSineExpression.__to_sql_func
629
+ PyLegendNumberSineExpression.__to_sql_func,
630
+ PyLegendNumberSineExpression.__to_pure_func
488
631
  )
489
632
 
490
633
 
@@ -498,12 +641,17 @@ class PyLegendNumberArcSineExpression(PyLegendUnaryExpression, PyLegendExpressio
498
641
  ) -> Expression:
499
642
  return ArcSineExpression(expression)
500
643
 
644
+ @staticmethod
645
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
646
+ return generate_pure_functional_call("asin", [op_expr], auto_map=True)
647
+
501
648
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
502
649
  PyLegendExpressionNumberReturn.__init__(self)
503
650
  PyLegendUnaryExpression.__init__(
504
651
  self,
505
652
  operand,
506
- PyLegendNumberArcSineExpression.__to_sql_func
653
+ PyLegendNumberArcSineExpression.__to_sql_func,
654
+ PyLegendNumberArcSineExpression.__to_pure_func
507
655
  )
508
656
 
509
657
 
@@ -517,12 +665,17 @@ class PyLegendNumberCosineExpression(PyLegendUnaryExpression, PyLegendExpression
517
665
  ) -> Expression:
518
666
  return CosineExpression(expression)
519
667
 
668
+ @staticmethod
669
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
670
+ return generate_pure_functional_call("cos", [op_expr], auto_map=True)
671
+
520
672
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
521
673
  PyLegendExpressionNumberReturn.__init__(self)
522
674
  PyLegendUnaryExpression.__init__(
523
675
  self,
524
676
  operand,
525
- PyLegendNumberCosineExpression.__to_sql_func
677
+ PyLegendNumberCosineExpression.__to_sql_func,
678
+ PyLegendNumberCosineExpression.__to_pure_func
526
679
  )
527
680
 
528
681
 
@@ -536,12 +689,17 @@ class PyLegendNumberArcCosineExpression(PyLegendUnaryExpression, PyLegendExpress
536
689
  ) -> Expression:
537
690
  return ArcCosineExpression(expression)
538
691
 
692
+ @staticmethod
693
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
694
+ return generate_pure_functional_call("acos", [op_expr], auto_map=True)
695
+
539
696
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
540
697
  PyLegendExpressionNumberReturn.__init__(self)
541
698
  PyLegendUnaryExpression.__init__(
542
699
  self,
543
700
  operand,
544
- PyLegendNumberArcCosineExpression.__to_sql_func
701
+ PyLegendNumberArcCosineExpression.__to_sql_func,
702
+ PyLegendNumberArcCosineExpression.__to_pure_func
545
703
  )
546
704
 
547
705
 
@@ -555,12 +713,17 @@ class PyLegendNumberTanExpression(PyLegendUnaryExpression, PyLegendExpressionNum
555
713
  ) -> Expression:
556
714
  return TanExpression(expression)
557
715
 
716
+ @staticmethod
717
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
718
+ return generate_pure_functional_call("tan", [op_expr], auto_map=True)
719
+
558
720
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
559
721
  PyLegendExpressionNumberReturn.__init__(self)
560
722
  PyLegendUnaryExpression.__init__(
561
723
  self,
562
724
  operand,
563
- PyLegendNumberTanExpression.__to_sql_func
725
+ PyLegendNumberTanExpression.__to_sql_func,
726
+ PyLegendNumberTanExpression.__to_pure_func
564
727
  )
565
728
 
566
729
 
@@ -574,12 +737,17 @@ class PyLegendNumberArcTanExpression(PyLegendUnaryExpression, PyLegendExpression
574
737
  ) -> Expression:
575
738
  return ArcTanExpression(expression)
576
739
 
740
+ @staticmethod
741
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
742
+ return generate_pure_functional_call("atan", [op_expr], auto_map=True)
743
+
577
744
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
578
745
  PyLegendExpressionNumberReturn.__init__(self)
579
746
  PyLegendUnaryExpression.__init__(
580
747
  self,
581
748
  operand,
582
- PyLegendNumberArcTanExpression.__to_sql_func
749
+ PyLegendNumberArcTanExpression.__to_sql_func,
750
+ PyLegendNumberArcTanExpression.__to_pure_func
583
751
  )
584
752
 
585
753
 
@@ -594,15 +762,23 @@ class PyLegendNumberArcTan2Expression(PyLegendBinaryExpression, PyLegendExpressi
594
762
  ) -> Expression:
595
763
  return ArcTan2Expression(expression1, expression2)
596
764
 
765
+ @staticmethod
766
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
767
+ return generate_pure_functional_call("atan2", [op1_expr, op2_expr], auto_map=True)
768
+
597
769
  def __init__(self, operand1: PyLegendExpressionNumberReturn, operand2: PyLegendExpressionNumberReturn) -> None:
598
770
  PyLegendExpressionNumberReturn.__init__(self)
599
771
  PyLegendBinaryExpression.__init__(
600
772
  self,
601
773
  operand1,
602
774
  operand2,
603
- PyLegendNumberArcTan2Expression.__to_sql_func
775
+ PyLegendNumberArcTan2Expression.__to_sql_func,
776
+ PyLegendNumberArcTan2Expression.__to_pure_func
604
777
  )
605
778
 
779
+ def to_pure_expression(self, config: FrameToPureConfig) -> str:
780
+ return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_second_operand(self, config)
781
+
606
782
 
607
783
  class PyLegendNumberCotExpression(PyLegendUnaryExpression, PyLegendExpressionNumberReturn):
608
784
 
@@ -614,10 +790,15 @@ class PyLegendNumberCotExpression(PyLegendUnaryExpression, PyLegendExpressionNum
614
790
  ) -> Expression:
615
791
  return CotExpression(expression)
616
792
 
793
+ @staticmethod
794
+ def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
795
+ return generate_pure_functional_call("cot", [op_expr], auto_map=True)
796
+
617
797
  def __init__(self, operand: PyLegendExpressionNumberReturn) -> None:
618
798
  PyLegendExpressionNumberReturn.__init__(self)
619
799
  PyLegendUnaryExpression.__init__(
620
800
  self,
621
801
  operand,
622
- PyLegendNumberCotExpression.__to_sql_func
802
+ PyLegendNumberCotExpression.__to_sql_func,
803
+ PyLegendNumberCotExpression.__to_pure_func
623
804
  )
@@ -16,11 +16,11 @@ from pylegend._typing import (
16
16
  PyLegendSequence,
17
17
  PyLegendDict,
18
18
  )
19
- from pylegend.core.language.expression import (
19
+ from pylegend.core.language.shared.expression import (
20
20
  PyLegendExpression,
21
21
  PyLegendExpressionBooleanReturn,
22
22
  )
23
- from pylegend.core.language.operations.binary_expression import PyLegendBinaryExpression
23
+ from pylegend.core.language.shared.operations.binary_expression import PyLegendBinaryExpression
24
24
  from pylegend.core.sql.metamodel import (
25
25
  Expression,
26
26
  QuerySpecification,
@@ -28,10 +28,12 @@ from pylegend.core.sql.metamodel import (
28
28
  ComparisonOperator,
29
29
  )
30
30
  from pylegend.core.tds.tds_frame import FrameToSqlConfig
31
+ from pylegend.core.tds.tds_frame import FrameToPureConfig
31
32
 
32
33
 
33
34
  __all__: PyLegendSequence[str] = [
34
35
  "PyLegendPrimitiveEqualsExpression",
36
+ "PyLegendPrimitiveNotEqualsExpression",
35
37
  ]
36
38
 
37
39
 
@@ -46,11 +48,48 @@ class PyLegendPrimitiveEqualsExpression(PyLegendBinaryExpression, PyLegendExpres
46
48
  ) -> Expression:
47
49
  return ComparisonExpression(expression1, expression2, ComparisonOperator.EQUAL)
48
50
 
51
+ @staticmethod
52
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
53
+ return f"({op1_expr} == {op2_expr})"
54
+
55
+ def __init__(self, operand1: PyLegendExpression, operand2: PyLegendExpression) -> None:
56
+ PyLegendExpressionBooleanReturn.__init__(self)
57
+ PyLegendBinaryExpression.__init__(
58
+ self,
59
+ operand1,
60
+ operand2,
61
+ PyLegendPrimitiveEqualsExpression.__to_sql_func,
62
+ PyLegendPrimitiveEqualsExpression.__to_pure_func
63
+ )
64
+
65
+ def is_non_nullable(self) -> bool:
66
+ return True
67
+
68
+
69
+ class PyLegendPrimitiveNotEqualsExpression(PyLegendBinaryExpression, PyLegendExpressionBooleanReturn):
70
+
71
+ @staticmethod
72
+ def __to_sql_func(
73
+ expression1: Expression,
74
+ expression2: Expression,
75
+ frame_name_to_base_query_map: PyLegendDict[str, QuerySpecification],
76
+ config: FrameToSqlConfig
77
+ ) -> Expression:
78
+ return ComparisonExpression(expression1, expression2, ComparisonOperator.NOT_EQUAL)
79
+
80
+ @staticmethod
81
+ def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
82
+ return f"({op1_expr} != {op2_expr})"
83
+
49
84
  def __init__(self, operand1: PyLegendExpression, operand2: PyLegendExpression) -> None:
50
85
  PyLegendExpressionBooleanReturn.__init__(self)
51
86
  PyLegendBinaryExpression.__init__(
52
87
  self,
53
88
  operand1,
54
89
  operand2,
55
- PyLegendPrimitiveEqualsExpression.__to_sql_func
90
+ PyLegendPrimitiveNotEqualsExpression.__to_sql_func,
91
+ PyLegendPrimitiveNotEqualsExpression.__to_pure_func
56
92
  )
93
+
94
+ def is_non_nullable(self) -> bool:
95
+ return True