pylegend 0.4.0__py3-none-any.whl → 0.6.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 -1
- pylegend/core/database/sql_to_string/db_extension.py +3 -0
- pylegend/core/language/__init__.py +2 -0
- pylegend/core/language/shared/functions.py +9 -0
- pylegend/core/language/shared/helpers.py +1 -9
- pylegend/core/language/shared/operations/binary_expression.py +22 -22
- pylegend/core/language/shared/operations/boolean_operation_expressions.py +13 -16
- pylegend/core/language/shared/operations/date_operation_expressions.py +208 -42
- pylegend/core/language/shared/operations/float_operation_expressions.py +20 -25
- pylegend/core/language/shared/operations/integer_operation_expressions.py +25 -30
- pylegend/core/language/shared/operations/nullary_expression.py +6 -1
- pylegend/core/language/shared/operations/number_operation_expressions.py +109 -90
- pylegend/core/language/shared/operations/primitive_operation_expressions.py +59 -7
- pylegend/core/language/shared/operations/string_operation_expressions.py +67 -25
- pylegend/core/language/shared/operations/unary_expression.py +16 -1
- pylegend/core/language/shared/primitives/date.py +37 -0
- pylegend/core/language/shared/primitives/primitive.py +16 -0
- pylegend/core/sql/metamodel_extension.py +12 -0
- {pylegend-0.4.0.dist-info → pylegend-0.6.0.dist-info}/METADATA +1 -1
- {pylegend-0.4.0.dist-info → pylegend-0.6.0.dist-info}/RECORD +24 -24
- {pylegend-0.4.0.dist-info → pylegend-0.6.0.dist-info}/LICENSE +0 -0
- {pylegend-0.4.0.dist-info → pylegend-0.6.0.dist-info}/LICENSE.spdx +0 -0
- {pylegend-0.4.0.dist-info → pylegend-0.6.0.dist-info}/NOTICE +0 -0
- {pylegend-0.4.0.dist-info → pylegend-0.6.0.dist-info}/WHEEL +0 -0
|
@@ -20,12 +20,16 @@ from pylegend.core.language.shared.expression import (
|
|
|
20
20
|
PyLegendExpression,
|
|
21
21
|
PyLegendExpressionBooleanReturn,
|
|
22
22
|
)
|
|
23
|
+
from pylegend.core.language.shared.helpers import generate_pure_functional_call
|
|
23
24
|
from pylegend.core.language.shared.operations.binary_expression import PyLegendBinaryExpression
|
|
25
|
+
from pylegend.core.language.shared.operations.unary_expression import PyLegendUnaryExpression
|
|
24
26
|
from pylegend.core.sql.metamodel import (
|
|
25
27
|
Expression,
|
|
26
28
|
QuerySpecification,
|
|
27
29
|
ComparisonExpression,
|
|
28
30
|
ComparisonOperator,
|
|
31
|
+
IsNullPredicate,
|
|
32
|
+
IsNotNullPredicate,
|
|
29
33
|
)
|
|
30
34
|
from pylegend.core.tds.tds_frame import FrameToSqlConfig
|
|
31
35
|
from pylegend.core.tds.tds_frame import FrameToPureConfig
|
|
@@ -34,6 +38,8 @@ from pylegend.core.tds.tds_frame import FrameToPureConfig
|
|
|
34
38
|
__all__: PyLegendSequence[str] = [
|
|
35
39
|
"PyLegendPrimitiveEqualsExpression",
|
|
36
40
|
"PyLegendPrimitiveNotEqualsExpression",
|
|
41
|
+
"PyLegendIsEmptyExpression",
|
|
42
|
+
"PyLegendIsNotEmptyExpression",
|
|
37
43
|
]
|
|
38
44
|
|
|
39
45
|
|
|
@@ -59,12 +65,10 @@ class PyLegendPrimitiveEqualsExpression(PyLegendBinaryExpression, PyLegendExpres
|
|
|
59
65
|
operand1,
|
|
60
66
|
operand2,
|
|
61
67
|
PyLegendPrimitiveEqualsExpression.__to_sql_func,
|
|
62
|
-
PyLegendPrimitiveEqualsExpression.__to_pure_func
|
|
68
|
+
PyLegendPrimitiveEqualsExpression.__to_pure_func,
|
|
69
|
+
non_nullable=True,
|
|
63
70
|
)
|
|
64
71
|
|
|
65
|
-
def is_non_nullable(self) -> bool:
|
|
66
|
-
return True
|
|
67
|
-
|
|
68
72
|
|
|
69
73
|
class PyLegendPrimitiveNotEqualsExpression(PyLegendBinaryExpression, PyLegendExpressionBooleanReturn):
|
|
70
74
|
|
|
@@ -88,8 +92,56 @@ class PyLegendPrimitiveNotEqualsExpression(PyLegendBinaryExpression, PyLegendExp
|
|
|
88
92
|
operand1,
|
|
89
93
|
operand2,
|
|
90
94
|
PyLegendPrimitiveNotEqualsExpression.__to_sql_func,
|
|
91
|
-
PyLegendPrimitiveNotEqualsExpression.__to_pure_func
|
|
95
|
+
PyLegendPrimitiveNotEqualsExpression.__to_pure_func,
|
|
96
|
+
non_nullable=True,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class PyLegendIsEmptyExpression(PyLegendUnaryExpression, PyLegendExpressionBooleanReturn):
|
|
101
|
+
|
|
102
|
+
@staticmethod
|
|
103
|
+
def __to_sql_func(
|
|
104
|
+
expression: Expression,
|
|
105
|
+
frame_name_to_base_query_map: PyLegendDict[str, QuerySpecification],
|
|
106
|
+
config: FrameToSqlConfig
|
|
107
|
+
) -> Expression:
|
|
108
|
+
return IsNullPredicate(expression)
|
|
109
|
+
|
|
110
|
+
@staticmethod
|
|
111
|
+
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
112
|
+
return generate_pure_functional_call("isEmpty", [op_expr])
|
|
113
|
+
|
|
114
|
+
def __init__(self, operand: PyLegendExpression) -> None:
|
|
115
|
+
PyLegendExpressionBooleanReturn.__init__(self)
|
|
116
|
+
PyLegendUnaryExpression.__init__(
|
|
117
|
+
self,
|
|
118
|
+
operand,
|
|
119
|
+
PyLegendIsEmptyExpression.__to_sql_func,
|
|
120
|
+
PyLegendIsEmptyExpression.__to_pure_func,
|
|
121
|
+
non_nullable=True,
|
|
92
122
|
)
|
|
93
123
|
|
|
94
|
-
|
|
95
|
-
|
|
124
|
+
|
|
125
|
+
class PyLegendIsNotEmptyExpression(PyLegendUnaryExpression, PyLegendExpressionBooleanReturn):
|
|
126
|
+
|
|
127
|
+
@staticmethod
|
|
128
|
+
def __to_sql_func(
|
|
129
|
+
expression: Expression,
|
|
130
|
+
frame_name_to_base_query_map: PyLegendDict[str, QuerySpecification],
|
|
131
|
+
config: FrameToSqlConfig
|
|
132
|
+
) -> Expression:
|
|
133
|
+
return IsNotNullPredicate(expression)
|
|
134
|
+
|
|
135
|
+
@staticmethod
|
|
136
|
+
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
137
|
+
return generate_pure_functional_call("isNotEmpty", [op_expr])
|
|
138
|
+
|
|
139
|
+
def __init__(self, operand: PyLegendExpression) -> None:
|
|
140
|
+
PyLegendExpressionBooleanReturn.__init__(self)
|
|
141
|
+
PyLegendUnaryExpression.__init__(
|
|
142
|
+
self,
|
|
143
|
+
operand,
|
|
144
|
+
PyLegendIsNotEmptyExpression.__to_sql_func,
|
|
145
|
+
PyLegendIsNotEmptyExpression.__to_pure_func,
|
|
146
|
+
non_nullable=True,
|
|
147
|
+
)
|
|
@@ -23,6 +23,7 @@ from pylegend.core.language.shared.expression import (
|
|
|
23
23
|
PyLegendExpressionBooleanReturn,
|
|
24
24
|
)
|
|
25
25
|
from pylegend.core.language.shared.operations.binary_expression import PyLegendBinaryExpression
|
|
26
|
+
from pylegend.core.language.shared.operations.nullary_expression import PyLegendNullaryExpression
|
|
26
27
|
from pylegend.core.language.shared.operations.unary_expression import PyLegendUnaryExpression
|
|
27
28
|
from pylegend.core.language.shared.helpers import generate_pure_functional_call
|
|
28
29
|
from pylegend.core.sql.metamodel import (
|
|
@@ -43,6 +44,7 @@ from pylegend.core.sql.metamodel_extension import (
|
|
|
43
44
|
StringTrimExpression,
|
|
44
45
|
StringPosExpression,
|
|
45
46
|
StringConcatExpression,
|
|
47
|
+
ConstantExpression,
|
|
46
48
|
)
|
|
47
49
|
from pylegend.core.tds.tds_frame import FrameToSqlConfig
|
|
48
50
|
from pylegend.core.tds.tds_frame import FrameToPureConfig
|
|
@@ -66,6 +68,7 @@ __all__: PyLegendSequence[str] = [
|
|
|
66
68
|
"PyLegendStringLessThanEqualExpression",
|
|
67
69
|
"PyLegendStringGreaterThanExpression",
|
|
68
70
|
"PyLegendStringGreaterThanEqualExpression",
|
|
71
|
+
"PyLegendCurrentUserExpression",
|
|
69
72
|
]
|
|
70
73
|
|
|
71
74
|
|
|
@@ -81,7 +84,7 @@ class PyLegendStringLengthExpression(PyLegendUnaryExpression, PyLegendExpression
|
|
|
81
84
|
|
|
82
85
|
@staticmethod
|
|
83
86
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
84
|
-
return generate_pure_functional_call("length", [op_expr]
|
|
87
|
+
return generate_pure_functional_call("length", [op_expr])
|
|
85
88
|
|
|
86
89
|
def __init__(self, operand: PyLegendExpressionStringReturn) -> None:
|
|
87
90
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -89,7 +92,9 @@ class PyLegendStringLengthExpression(PyLegendUnaryExpression, PyLegendExpression
|
|
|
89
92
|
self,
|
|
90
93
|
operand,
|
|
91
94
|
PyLegendStringLengthExpression.__to_sql_func,
|
|
92
|
-
PyLegendStringLengthExpression.__to_pure_func
|
|
95
|
+
PyLegendStringLengthExpression.__to_pure_func,
|
|
96
|
+
non_nullable=True,
|
|
97
|
+
operand_needs_to_be_non_nullable=True,
|
|
93
98
|
)
|
|
94
99
|
|
|
95
100
|
|
|
@@ -189,7 +194,7 @@ class PyLegendStringUpperExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
189
194
|
|
|
190
195
|
@staticmethod
|
|
191
196
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
192
|
-
return generate_pure_functional_call("toUpper", [op_expr]
|
|
197
|
+
return generate_pure_functional_call("toUpper", [op_expr])
|
|
193
198
|
|
|
194
199
|
def __init__(self, operand: PyLegendExpressionStringReturn) -> None:
|
|
195
200
|
PyLegendExpressionStringReturn.__init__(self)
|
|
@@ -197,7 +202,9 @@ class PyLegendStringUpperExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
197
202
|
self,
|
|
198
203
|
operand,
|
|
199
204
|
PyLegendStringUpperExpression.__to_sql_func,
|
|
200
|
-
PyLegendStringUpperExpression.__to_pure_func
|
|
205
|
+
PyLegendStringUpperExpression.__to_pure_func,
|
|
206
|
+
non_nullable=True,
|
|
207
|
+
operand_needs_to_be_non_nullable=True,
|
|
201
208
|
)
|
|
202
209
|
|
|
203
210
|
|
|
@@ -213,7 +220,7 @@ class PyLegendStringLowerExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
213
220
|
|
|
214
221
|
@staticmethod
|
|
215
222
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
216
|
-
return generate_pure_functional_call("toLower", [op_expr]
|
|
223
|
+
return generate_pure_functional_call("toLower", [op_expr])
|
|
217
224
|
|
|
218
225
|
def __init__(self, operand: PyLegendExpressionStringReturn) -> None:
|
|
219
226
|
PyLegendExpressionStringReturn.__init__(self)
|
|
@@ -221,7 +228,9 @@ class PyLegendStringLowerExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
221
228
|
self,
|
|
222
229
|
operand,
|
|
223
230
|
PyLegendStringLowerExpression.__to_sql_func,
|
|
224
|
-
PyLegendStringLowerExpression.__to_pure_func
|
|
231
|
+
PyLegendStringLowerExpression.__to_pure_func,
|
|
232
|
+
non_nullable=True,
|
|
233
|
+
operand_needs_to_be_non_nullable=True,
|
|
225
234
|
)
|
|
226
235
|
|
|
227
236
|
|
|
@@ -237,7 +246,7 @@ class PyLegendStringLTrimExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
237
246
|
|
|
238
247
|
@staticmethod
|
|
239
248
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
240
|
-
return generate_pure_functional_call("ltrim", [op_expr]
|
|
249
|
+
return generate_pure_functional_call("ltrim", [op_expr])
|
|
241
250
|
|
|
242
251
|
def __init__(self, operand: PyLegendExpressionStringReturn) -> None:
|
|
243
252
|
PyLegendExpressionStringReturn.__init__(self)
|
|
@@ -245,7 +254,9 @@ class PyLegendStringLTrimExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
245
254
|
self,
|
|
246
255
|
operand,
|
|
247
256
|
PyLegendStringLTrimExpression.__to_sql_func,
|
|
248
|
-
PyLegendStringLTrimExpression.__to_pure_func
|
|
257
|
+
PyLegendStringLTrimExpression.__to_pure_func,
|
|
258
|
+
non_nullable=True,
|
|
259
|
+
operand_needs_to_be_non_nullable=True,
|
|
249
260
|
)
|
|
250
261
|
|
|
251
262
|
|
|
@@ -261,7 +272,7 @@ class PyLegendStringRTrimExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
261
272
|
|
|
262
273
|
@staticmethod
|
|
263
274
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
264
|
-
return generate_pure_functional_call("rtrim", [op_expr]
|
|
275
|
+
return generate_pure_functional_call("rtrim", [op_expr])
|
|
265
276
|
|
|
266
277
|
def __init__(self, operand: PyLegendExpressionStringReturn) -> None:
|
|
267
278
|
PyLegendExpressionStringReturn.__init__(self)
|
|
@@ -269,7 +280,9 @@ class PyLegendStringRTrimExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
269
280
|
self,
|
|
270
281
|
operand,
|
|
271
282
|
PyLegendStringRTrimExpression.__to_sql_func,
|
|
272
|
-
PyLegendStringRTrimExpression.__to_pure_func
|
|
283
|
+
PyLegendStringRTrimExpression.__to_pure_func,
|
|
284
|
+
non_nullable=True,
|
|
285
|
+
operand_needs_to_be_non_nullable=True,
|
|
273
286
|
)
|
|
274
287
|
|
|
275
288
|
|
|
@@ -285,7 +298,7 @@ class PyLegendStringBTrimExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
285
298
|
|
|
286
299
|
@staticmethod
|
|
287
300
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
288
|
-
return generate_pure_functional_call("trim", [op_expr]
|
|
301
|
+
return generate_pure_functional_call("trim", [op_expr])
|
|
289
302
|
|
|
290
303
|
def __init__(self, operand: PyLegendExpressionStringReturn) -> None:
|
|
291
304
|
PyLegendExpressionStringReturn.__init__(self)
|
|
@@ -293,7 +306,9 @@ class PyLegendStringBTrimExpression(PyLegendUnaryExpression, PyLegendExpressionS
|
|
|
293
306
|
self,
|
|
294
307
|
operand,
|
|
295
308
|
PyLegendStringBTrimExpression.__to_sql_func,
|
|
296
|
-
PyLegendStringBTrimExpression.__to_pure_func
|
|
309
|
+
PyLegendStringBTrimExpression.__to_pure_func,
|
|
310
|
+
non_nullable=True,
|
|
311
|
+
operand_needs_to_be_non_nullable=True,
|
|
297
312
|
)
|
|
298
313
|
|
|
299
314
|
|
|
@@ -310,7 +325,7 @@ class PyLegendStringPosExpression(PyLegendBinaryExpression, PyLegendExpressionIn
|
|
|
310
325
|
|
|
311
326
|
@staticmethod
|
|
312
327
|
def __to_pure_func(op1_expr: str, op2_expr: str, config: FrameToPureConfig) -> str:
|
|
313
|
-
return generate_pure_functional_call("indexOf", [op1_expr, op2_expr]
|
|
328
|
+
return generate_pure_functional_call("indexOf", [op1_expr, op2_expr])
|
|
314
329
|
|
|
315
330
|
def __init__(self, operand1: PyLegendExpressionStringReturn, operand2: PyLegendExpressionStringReturn) -> None:
|
|
316
331
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -319,12 +334,12 @@ class PyLegendStringPosExpression(PyLegendBinaryExpression, PyLegendExpressionIn
|
|
|
319
334
|
operand1,
|
|
320
335
|
operand2,
|
|
321
336
|
PyLegendStringPosExpression.__to_sql_func,
|
|
322
|
-
PyLegendStringPosExpression.__to_pure_func
|
|
337
|
+
PyLegendStringPosExpression.__to_pure_func,
|
|
338
|
+
non_nullable=True,
|
|
339
|
+
first_operand_needs_to_be_non_nullable=True,
|
|
340
|
+
second_operand_needs_to_be_non_nullable=True
|
|
323
341
|
)
|
|
324
342
|
|
|
325
|
-
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
326
|
-
return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_second_operand(self, config)
|
|
327
|
-
|
|
328
343
|
|
|
329
344
|
class PyLegendStringParseIntExpression(PyLegendUnaryExpression, PyLegendExpressionIntegerReturn):
|
|
330
345
|
|
|
@@ -338,7 +353,7 @@ class PyLegendStringParseIntExpression(PyLegendUnaryExpression, PyLegendExpressi
|
|
|
338
353
|
|
|
339
354
|
@staticmethod
|
|
340
355
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
341
|
-
return generate_pure_functional_call("parseInteger", [op_expr]
|
|
356
|
+
return generate_pure_functional_call("parseInteger", [op_expr])
|
|
342
357
|
|
|
343
358
|
def __init__(self, operand: PyLegendExpressionStringReturn) -> None:
|
|
344
359
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -346,7 +361,9 @@ class PyLegendStringParseIntExpression(PyLegendUnaryExpression, PyLegendExpressi
|
|
|
346
361
|
self,
|
|
347
362
|
operand,
|
|
348
363
|
PyLegendStringParseIntExpression.__to_sql_func,
|
|
349
|
-
PyLegendStringParseIntExpression.__to_pure_func
|
|
364
|
+
PyLegendStringParseIntExpression.__to_pure_func,
|
|
365
|
+
non_nullable=True,
|
|
366
|
+
operand_needs_to_be_non_nullable=True,
|
|
350
367
|
)
|
|
351
368
|
|
|
352
369
|
|
|
@@ -362,7 +379,7 @@ class PyLegendStringParseFloatExpression(PyLegendUnaryExpression, PyLegendExpres
|
|
|
362
379
|
|
|
363
380
|
@staticmethod
|
|
364
381
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
365
|
-
return generate_pure_functional_call("parseFloat", [op_expr]
|
|
382
|
+
return generate_pure_functional_call("parseFloat", [op_expr])
|
|
366
383
|
|
|
367
384
|
def __init__(self, operand: PyLegendExpressionStringReturn) -> None:
|
|
368
385
|
PyLegendExpressionFloatReturn.__init__(self)
|
|
@@ -370,7 +387,9 @@ class PyLegendStringParseFloatExpression(PyLegendUnaryExpression, PyLegendExpres
|
|
|
370
387
|
self,
|
|
371
388
|
operand,
|
|
372
389
|
PyLegendStringParseFloatExpression.__to_sql_func,
|
|
373
|
-
PyLegendStringParseFloatExpression.__to_pure_func
|
|
390
|
+
PyLegendStringParseFloatExpression.__to_pure_func,
|
|
391
|
+
non_nullable=True,
|
|
392
|
+
operand_needs_to_be_non_nullable=True,
|
|
374
393
|
)
|
|
375
394
|
|
|
376
395
|
|
|
@@ -396,12 +415,12 @@ class PyLegendStringConcatExpression(PyLegendBinaryExpression, PyLegendExpressio
|
|
|
396
415
|
operand1,
|
|
397
416
|
operand2,
|
|
398
417
|
PyLegendStringConcatExpression.__to_sql_func,
|
|
399
|
-
PyLegendStringConcatExpression.__to_pure_func
|
|
418
|
+
PyLegendStringConcatExpression.__to_pure_func,
|
|
419
|
+
non_nullable=True,
|
|
420
|
+
first_operand_needs_to_be_non_nullable=True,
|
|
421
|
+
second_operand_needs_to_be_non_nullable=True
|
|
400
422
|
)
|
|
401
423
|
|
|
402
|
-
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
403
|
-
return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
|
|
404
|
-
|
|
405
424
|
|
|
406
425
|
class PyLegendStringLessThanExpression(PyLegendBinaryExpression, PyLegendExpressionBooleanReturn):
|
|
407
426
|
|
|
@@ -507,5 +526,28 @@ class PyLegendStringGreaterThanEqualExpression(PyLegendBinaryExpression, PyLegen
|
|
|
507
526
|
)
|
|
508
527
|
|
|
509
528
|
|
|
529
|
+
class PyLegendCurrentUserExpression(PyLegendNullaryExpression, PyLegendExpressionStringReturn):
|
|
530
|
+
|
|
531
|
+
@staticmethod
|
|
532
|
+
def __to_sql_func(
|
|
533
|
+
frame_name_to_base_query_map: PyLegendDict[str, QuerySpecification],
|
|
534
|
+
config: FrameToSqlConfig
|
|
535
|
+
) -> Expression:
|
|
536
|
+
return ConstantExpression('CURRENT_USER')
|
|
537
|
+
|
|
538
|
+
@staticmethod
|
|
539
|
+
def __to_pure_func(config: FrameToPureConfig) -> str:
|
|
540
|
+
return "currentUserId()"
|
|
541
|
+
|
|
542
|
+
def __init__(self) -> None:
|
|
543
|
+
PyLegendExpressionStringReturn.__init__(self)
|
|
544
|
+
PyLegendNullaryExpression.__init__(
|
|
545
|
+
self,
|
|
546
|
+
PyLegendCurrentUserExpression.__to_sql_func,
|
|
547
|
+
PyLegendCurrentUserExpression.__to_pure_func,
|
|
548
|
+
non_nullable=True
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
|
|
510
552
|
def _escape_like_param(param: str) -> str:
|
|
511
553
|
return param.replace("_", "\\_").replace("%", "\\%")
|
|
@@ -21,6 +21,7 @@ from pylegend._typing import (
|
|
|
21
21
|
from pylegend.core.language.shared.expression import (
|
|
22
22
|
PyLegendExpression,
|
|
23
23
|
)
|
|
24
|
+
from pylegend.core.language.shared.helpers import expr_has_matching_start_and_end_parentheses
|
|
24
25
|
from pylegend.core.sql.metamodel import (
|
|
25
26
|
Expression,
|
|
26
27
|
QuerySpecification,
|
|
@@ -41,6 +42,8 @@ class PyLegendUnaryExpression(PyLegendExpression, metaclass=ABCMeta):
|
|
|
41
42
|
Expression
|
|
42
43
|
]
|
|
43
44
|
__to_pure_func: PyLegendCallable[[str, FrameToPureConfig], str]
|
|
45
|
+
__non_nullable: bool
|
|
46
|
+
__operand_needs_to_be_non_nullable: bool
|
|
44
47
|
|
|
45
48
|
def __init__(
|
|
46
49
|
self,
|
|
@@ -49,11 +52,15 @@ class PyLegendUnaryExpression(PyLegendExpression, metaclass=ABCMeta):
|
|
|
49
52
|
[Expression, PyLegendDict[str, QuerySpecification], FrameToSqlConfig],
|
|
50
53
|
Expression
|
|
51
54
|
],
|
|
52
|
-
to_pure_func: PyLegendCallable[[str, FrameToPureConfig], str]
|
|
55
|
+
to_pure_func: PyLegendCallable[[str, FrameToPureConfig], str],
|
|
56
|
+
non_nullable: bool = False,
|
|
57
|
+
operand_needs_to_be_non_nullable: bool = False,
|
|
53
58
|
) -> None:
|
|
54
59
|
self.__operand = operand
|
|
55
60
|
self.__to_sql_func = to_sql_func
|
|
56
61
|
self.__to_pure_func = to_pure_func
|
|
62
|
+
self.__non_nullable = non_nullable
|
|
63
|
+
self.__operand_needs_to_be_non_nullable = operand_needs_to_be_non_nullable
|
|
57
64
|
|
|
58
65
|
def to_sql_expression(
|
|
59
66
|
self,
|
|
@@ -69,4 +76,12 @@ class PyLegendUnaryExpression(PyLegendExpression, metaclass=ABCMeta):
|
|
|
69
76
|
|
|
70
77
|
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
71
78
|
op_expr = self.__operand.to_pure_expression(config)
|
|
79
|
+
if self.__operand_needs_to_be_non_nullable:
|
|
80
|
+
op_expr = (
|
|
81
|
+
op_expr if self.__operand.is_non_nullable() else
|
|
82
|
+
f"toOne({op_expr[1:-1] if expr_has_matching_start_and_end_parentheses(op_expr) else op_expr})"
|
|
83
|
+
)
|
|
72
84
|
return self.__to_pure_func(op_expr, config)
|
|
85
|
+
|
|
86
|
+
def is_non_nullable(self) -> bool:
|
|
87
|
+
return self.__non_nullable
|
|
@@ -21,6 +21,7 @@ from pylegend._typing import (
|
|
|
21
21
|
)
|
|
22
22
|
from pylegend.core.language.shared.primitives.primitive import PyLegendPrimitive
|
|
23
23
|
from pylegend.core.language.shared.primitives.integer import PyLegendInteger
|
|
24
|
+
from pylegend.core.language.shared.primitives.boolean import PyLegendBoolean
|
|
24
25
|
from pylegend.core.language.shared.expression import (
|
|
25
26
|
PyLegendExpressionDateReturn,
|
|
26
27
|
)
|
|
@@ -49,6 +50,10 @@ from pylegend.core.language.shared.operations.date_operation_expressions import
|
|
|
49
50
|
PyLegendSecondExpression,
|
|
50
51
|
PyLegendEpochExpression,
|
|
51
52
|
PyLegendDatePartExpression,
|
|
53
|
+
PyLegendDateLessThanExpression,
|
|
54
|
+
PyLegendDateLessThanEqualExpression,
|
|
55
|
+
PyLegendDateGreaterThanExpression,
|
|
56
|
+
PyLegendDateGreaterThanEqualExpression,
|
|
52
57
|
)
|
|
53
58
|
from pylegend.core.sql.metamodel import (
|
|
54
59
|
Expression,
|
|
@@ -153,6 +158,38 @@ class PyLegendDate(PyLegendPrimitive):
|
|
|
153
158
|
from pylegend.core.language.shared.primitives.strictdate import PyLegendStrictDate
|
|
154
159
|
return PyLegendStrictDate(PyLegendDatePartExpression(self.__value))
|
|
155
160
|
|
|
161
|
+
def __lt__(
|
|
162
|
+
self,
|
|
163
|
+
other: PyLegendUnion[date, datetime, "PyLegendStrictDate", "PyLegendDateTime", "PyLegendDate"]
|
|
164
|
+
) -> "PyLegendBoolean":
|
|
165
|
+
PyLegendDate.validate_param_to_be_date(other, "Date less than (<) parameter")
|
|
166
|
+
other_op = PyLegendDate.__convert_to_date_expr(other)
|
|
167
|
+
return PyLegendBoolean(PyLegendDateLessThanExpression(self.__value, other_op))
|
|
168
|
+
|
|
169
|
+
def __le__(
|
|
170
|
+
self,
|
|
171
|
+
other: PyLegendUnion[date, datetime, "PyLegendStrictDate", "PyLegendDateTime", "PyLegendDate"]
|
|
172
|
+
) -> "PyLegendBoolean":
|
|
173
|
+
PyLegendDate.validate_param_to_be_date(other, "Date less than equal (<=) parameter")
|
|
174
|
+
other_op = PyLegendDate.__convert_to_date_expr(other)
|
|
175
|
+
return PyLegendBoolean(PyLegendDateLessThanEqualExpression(self.__value, other_op))
|
|
176
|
+
|
|
177
|
+
def __gt__(
|
|
178
|
+
self,
|
|
179
|
+
other: PyLegendUnion[date, datetime, "PyLegendStrictDate", "PyLegendDateTime", "PyLegendDate"]
|
|
180
|
+
) -> "PyLegendBoolean":
|
|
181
|
+
PyLegendDate.validate_param_to_be_date(other, "Date greater than (>) parameter")
|
|
182
|
+
other_op = PyLegendDate.__convert_to_date_expr(other)
|
|
183
|
+
return PyLegendBoolean(PyLegendDateGreaterThanExpression(self.__value, other_op))
|
|
184
|
+
|
|
185
|
+
def __ge__(
|
|
186
|
+
self,
|
|
187
|
+
other: PyLegendUnion[date, datetime, "PyLegendStrictDate", "PyLegendDateTime", "PyLegendDate"]
|
|
188
|
+
) -> "PyLegendBoolean":
|
|
189
|
+
PyLegendDate.validate_param_to_be_date(other, "Date greater than equal (>=) parameter")
|
|
190
|
+
other_op = PyLegendDate.__convert_to_date_expr(other)
|
|
191
|
+
return PyLegendBoolean(PyLegendDateGreaterThanEqualExpression(self.__value, other_op))
|
|
192
|
+
|
|
156
193
|
@staticmethod
|
|
157
194
|
def __convert_to_date_expr(
|
|
158
195
|
val: PyLegendUnion[date, datetime, "PyLegendDateTime", "PyLegendStrictDate", "PyLegendDate"]
|
|
@@ -30,6 +30,8 @@ from pylegend.core.language.shared.literal_expressions import convert_literal_to
|
|
|
30
30
|
from pylegend.core.language.shared.operations.primitive_operation_expressions import (
|
|
31
31
|
PyLegendPrimitiveEqualsExpression,
|
|
32
32
|
PyLegendPrimitiveNotEqualsExpression,
|
|
33
|
+
PyLegendIsEmptyExpression,
|
|
34
|
+
PyLegendIsNotEmptyExpression,
|
|
33
35
|
)
|
|
34
36
|
from pylegend.core.tds.tds_frame import FrameToSqlConfig
|
|
35
37
|
from pylegend.core.tds.tds_frame import FrameToPureConfig
|
|
@@ -84,6 +86,20 @@ class PyLegendPrimitive(metaclass=ABCMeta):
|
|
|
84
86
|
from pylegend.core.language.shared.primitives.boolean import PyLegendBoolean
|
|
85
87
|
return PyLegendBoolean(PyLegendPrimitiveNotEqualsExpression(self.value(), other_op))
|
|
86
88
|
|
|
89
|
+
def is_empty(self) -> "PyLegendBoolean":
|
|
90
|
+
from pylegend.core.language.shared.primitives.boolean import PyLegendBoolean
|
|
91
|
+
return PyLegendBoolean(PyLegendIsEmptyExpression(self.value()))
|
|
92
|
+
|
|
93
|
+
def is_null(self) -> "PyLegendBoolean":
|
|
94
|
+
return self.is_empty()
|
|
95
|
+
|
|
96
|
+
def is_not_empty(self) -> "PyLegendBoolean":
|
|
97
|
+
from pylegend.core.language.shared.primitives.boolean import PyLegendBoolean
|
|
98
|
+
return PyLegendBoolean(PyLegendIsNotEmptyExpression(self.value()))
|
|
99
|
+
|
|
100
|
+
def is_not_null(self) -> "PyLegendBoolean":
|
|
101
|
+
return self.is_not_empty()
|
|
102
|
+
|
|
87
103
|
@staticmethod
|
|
88
104
|
def __validate_param_to_be_primitive(
|
|
89
105
|
param: "PyLegendUnion[int, float, bool, str, date, datetime, PyLegendPrimitive]",
|
|
@@ -80,6 +80,7 @@ __all__: PyLegendSequence[str] = [
|
|
|
80
80
|
"SecondExpression",
|
|
81
81
|
"EpochExpression",
|
|
82
82
|
"WindowExpression",
|
|
83
|
+
"ConstantExpression",
|
|
83
84
|
]
|
|
84
85
|
|
|
85
86
|
|
|
@@ -733,3 +734,14 @@ class WindowExpression(Expression):
|
|
|
733
734
|
super().__init__(_type="windowExpression")
|
|
734
735
|
self.nested = nested
|
|
735
736
|
self.window = window
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
class ConstantExpression(Expression):
|
|
740
|
+
name: str
|
|
741
|
+
|
|
742
|
+
def __init__(
|
|
743
|
+
self,
|
|
744
|
+
name: str
|
|
745
|
+
) -> None:
|
|
746
|
+
super().__init__(_type="constantExpression")
|
|
747
|
+
self.name = name
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
pylegend/__init__.py,sha256=
|
|
1
|
+
pylegend/__init__.py,sha256=gYOX0h2mTsQ_miZfuHosVzYR9O_IZjTP1FAum3naIW4,1668
|
|
2
2
|
pylegend/_typing.py,sha256=3P2K9xyyODrYRx3iDI8jtF1vGGqPbYiKqLEN9bBCdi0,1479
|
|
3
3
|
pylegend/core/__init__.py,sha256=LXTDJSDmHQXtnMDZouhZp9IZQVpY6ONkINbUYjtnMkE,578
|
|
4
4
|
pylegend/core/database/__init__.py,sha256=LXTDJSDmHQXtnMDZouhZp9IZQVpY6ONkINbUYjtnMkE,578
|
|
5
5
|
pylegend/core/database/sql_to_string/__init__.py,sha256=_qWOoReR9ygprnShQRBtp4wFmqtiPEa88jAhOZpYY2c,1028
|
|
6
6
|
pylegend/core/database/sql_to_string/config.py,sha256=xrwPFcuZyzZcKNGeOQTnFW2y7CqhT6laSAazVl93JLU,1384
|
|
7
|
-
pylegend/core/database/sql_to_string/db_extension.py,sha256=
|
|
7
|
+
pylegend/core/database/sql_to_string/db_extension.py,sha256=dCSz9Sc4iXWsn3u9gaMAzyZsYa1ytQ8TeeAEHBWeGOE,52986
|
|
8
8
|
pylegend/core/database/sql_to_string/generator.py,sha256=xk3siXWyR7_ahn6pwsUMi80V_7NV2tYa7x5dosiNJR4,2607
|
|
9
|
-
pylegend/core/language/__init__.py,sha256=
|
|
9
|
+
pylegend/core/language/__init__.py,sha256=sw70dEA5RT660Qmpjxdi1XKEWDwshuedomqHhyIJpvI,4331
|
|
10
10
|
pylegend/core/language/legacy_api/__init__.py,sha256=g6w4WCuQ2pqQG6yyn-QLLXED3ttOOB8YnXzVt3ijb28,578
|
|
11
11
|
pylegend/core/language/legacy_api/aggregate_specification.py,sha256=XT9kmlT3DqrJRUbQSju69ZW-23mORnJHE_Aplw_YpNw,2207
|
|
12
12
|
pylegend/core/language/legacy_api/legacy_api_tds_row.py,sha256=B3L55ylNVnHoukuETEyU7zPS5E_G9H8hSesGN48zgkM,1149
|
|
@@ -16,30 +16,30 @@ pylegend/core/language/legendql_api/legendql_api_tds_row.py,sha256=5hejBF2uYjXua
|
|
|
16
16
|
pylegend/core/language/shared/__init__.py,sha256=g6w4WCuQ2pqQG6yyn-QLLXED3ttOOB8YnXzVt3ijb28,578
|
|
17
17
|
pylegend/core/language/shared/column_expressions.py,sha256=qWHVvwPGwKroQX94a_ovUrxCPnosVMX3tBWlTj7uJ6k,4333
|
|
18
18
|
pylegend/core/language/shared/expression.py,sha256=-XDJ3JfkyQ2FunACUEGI4CeTgqCvBexp55_YCaZUD1k,2446
|
|
19
|
-
pylegend/core/language/shared/functions.py,sha256=
|
|
20
|
-
pylegend/core/language/shared/helpers.py,sha256=
|
|
19
|
+
pylegend/core/language/shared/functions.py,sha256=G94EiFdZV4jorJTX23ErxKP1GusKl61G3qQN1e26Zws,1495
|
|
20
|
+
pylegend/core/language/shared/helpers.py,sha256=E7IKZwb__qj4_JpoBT2cra_umvfKP58c5U5bygMqh_o,2379
|
|
21
21
|
pylegend/core/language/shared/literal_expressions.py,sha256=bU9pO-H9DxNyDlWVMiJC__YPzHQLo_v9aedllozBzVo,6185
|
|
22
22
|
pylegend/core/language/shared/operations/__init__.py,sha256=LXTDJSDmHQXtnMDZouhZp9IZQVpY6ONkINbUYjtnMkE,578
|
|
23
|
-
pylegend/core/language/shared/operations/binary_expression.py,sha256=
|
|
24
|
-
pylegend/core/language/shared/operations/boolean_operation_expressions.py,sha256=
|
|
23
|
+
pylegend/core/language/shared/operations/binary_expression.py,sha256=I3CIWwbKlKq1R8ekUXY8QKyHro8b7fIgeM8hTPwN5jA,4006
|
|
24
|
+
pylegend/core/language/shared/operations/boolean_operation_expressions.py,sha256=6NYAilcC6QEn4J_mWTZdDCJhbPMam36Xl6Ai9N1kJsQ,4630
|
|
25
25
|
pylegend/core/language/shared/operations/collection_operation_expressions.py,sha256=PuyICSjPadQNWkp8aZnCZblRnG_uh7lPEXMDN9nwKRI,22412
|
|
26
|
-
pylegend/core/language/shared/operations/date_operation_expressions.py,sha256=
|
|
27
|
-
pylegend/core/language/shared/operations/float_operation_expressions.py,sha256=
|
|
28
|
-
pylegend/core/language/shared/operations/integer_operation_expressions.py,sha256=
|
|
29
|
-
pylegend/core/language/shared/operations/nullary_expression.py,sha256=
|
|
30
|
-
pylegend/core/language/shared/operations/number_operation_expressions.py,sha256=
|
|
31
|
-
pylegend/core/language/shared/operations/primitive_operation_expressions.py,sha256=
|
|
32
|
-
pylegend/core/language/shared/operations/string_operation_expressions.py,sha256=
|
|
33
|
-
pylegend/core/language/shared/operations/unary_expression.py,sha256=
|
|
26
|
+
pylegend/core/language/shared/operations/date_operation_expressions.py,sha256=NFgOjS2GyviFIq2eR7wT1niO2NIGr8FeeYNIhmDjig0,27905
|
|
27
|
+
pylegend/core/language/shared/operations/float_operation_expressions.py,sha256=GsKflYlswzfvb2eEqObRgcoO218zdNj3atS-5g8YzJI,6849
|
|
28
|
+
pylegend/core/language/shared/operations/integer_operation_expressions.py,sha256=4LcGyJvGyraoSP26_JI6VhLGETahKiVVG9qEvMIBt4U,8142
|
|
29
|
+
pylegend/core/language/shared/operations/nullary_expression.py,sha256=dMq3hi7_t0TFboOoQQHjuNZ7D9hLYfc_NozNaUCJTtI,2242
|
|
30
|
+
pylegend/core/language/shared/operations/number_operation_expressions.py,sha256=sqbjVocq2YwuevLGrpBzg7pJch6QmCYYcqZGK62UsiY,30367
|
|
31
|
+
pylegend/core/language/shared/operations/primitive_operation_expressions.py,sha256=UsNe3RN_HuxIfQwcWI6l2xtTgrLIbrJd2nRPJYCTsXA,5297
|
|
32
|
+
pylegend/core/language/shared/operations/string_operation_expressions.py,sha256=90T02mRtJ2lHSPauD-HXeKyNEVFaJB-Cg4HVQbPGAMk,20886
|
|
33
|
+
pylegend/core/language/shared/operations/unary_expression.py,sha256=1VWE43rN4x4NLc6aL3xRzleK9c_UfrLawlyYgX3SG48,3132
|
|
34
34
|
pylegend/core/language/shared/primitive_collection.py,sha256=ShUtgdZkZ8cKdQJLP5iU_zYDK7piMzWlimvjhnyfnGk,13098
|
|
35
35
|
pylegend/core/language/shared/primitives/__init__.py,sha256=9p7VVRhzeRQwTkxXQBBZuJY6P9V-yX0Q_elviaYIgPg,1649
|
|
36
36
|
pylegend/core/language/shared/primitives/boolean.py,sha256=x0JgS8E9AXv0fkExuCCyD9Paim2xwfU9cn-1Jh3bqtI,4058
|
|
37
|
-
pylegend/core/language/shared/primitives/date.py,sha256=
|
|
37
|
+
pylegend/core/language/shared/primitives/date.py,sha256=CFiz6LquJIUHBIdHGZ5j16wYcw-Bo4nYHeM7Hne1EWI,9062
|
|
38
38
|
pylegend/core/language/shared/primitives/datetime.py,sha256=F8m-pLm_VcefI-_iF8CCjbi-AZKzrXxqyuXZtxJB_AU,2495
|
|
39
39
|
pylegend/core/language/shared/primitives/float.py,sha256=LpD3nWogv8aT6RECgI7rVmsRPY4ji96JCXdTEAr2EAg,6146
|
|
40
40
|
pylegend/core/language/shared/primitives/integer.py,sha256=dXccyccyR9UWlqTlTobTdl4PrSy7W9NPDnJKCVewJ9w,7334
|
|
41
41
|
pylegend/core/language/shared/primitives/number.py,sha256=bYqBFtsauUGijP1kqRuSYDSTIVokU0b-paFH3uZGQZU,13699
|
|
42
|
-
pylegend/core/language/shared/primitives/primitive.py,sha256=
|
|
42
|
+
pylegend/core/language/shared/primitives/primitive.py,sha256=RUirddeU8kMV-wqeo2Kju7eyisY6epddIUWxZXKuKmg,4486
|
|
43
43
|
pylegend/core/language/shared/primitives/strictdate.py,sha256=FidyUqdWTaOrk6tomYHQvhfnGW--zVTt9ldIgGxJk5M,2503
|
|
44
44
|
pylegend/core/language/shared/primitives/string.py,sha256=qjiKaR5wioL8tz55BnTENtKlOGP4d1G0cVP-WhYMNrs,8282
|
|
45
45
|
pylegend/core/language/shared/tds_row.py,sha256=23sxVfa74T-TlfAs1CgvwjhV26b-FyZ72yGy9BqP7CE,9027
|
|
@@ -51,7 +51,7 @@ pylegend/core/request/response_reader.py,sha256=TNMi2GKk4lkmf7VMeY5n2AwhxxuWbX4M
|
|
|
51
51
|
pylegend/core/request/service_client.py,sha256=oNvMR6qNl5UcxpcAjIb4CCpd0MB3Z-Y5OJSyFPGeerM,3377
|
|
52
52
|
pylegend/core/sql/__init__.py,sha256=LXTDJSDmHQXtnMDZouhZp9IZQVpY6ONkINbUYjtnMkE,578
|
|
53
53
|
pylegend/core/sql/metamodel.py,sha256=B7aqblDyyiTsqWZUW2Is9_2FHTsYTkvhJ1FVxXxoSF8,20134
|
|
54
|
-
pylegend/core/sql/metamodel_extension.py,sha256=
|
|
54
|
+
pylegend/core/sql/metamodel_extension.py,sha256=B53DUH4nXPWqMmbcfmLAHvJHX370J0Ml_eYdJzASbJE,15905
|
|
55
55
|
pylegend/core/tds/__init__.py,sha256=LXTDJSDmHQXtnMDZouhZp9IZQVpY6ONkINbUYjtnMkE,578
|
|
56
56
|
pylegend/core/tds/abstract/__init__.py,sha256=g6w4WCuQ2pqQG6yyn-QLLXED3ttOOB8YnXzVt3ijb28,578
|
|
57
57
|
pylegend/core/tds/abstract/frames/__init__.py,sha256=g6w4WCuQ2pqQG6yyn-QLLXED3ttOOB8YnXzVt3ijb28,578
|
|
@@ -147,9 +147,9 @@ pylegend/extensions/tds/result_handler/to_pandas_df_result_handler.py,sha256=tvV
|
|
|
147
147
|
pylegend/legacy_api_tds_client.py,sha256=IXfo2pdBFV3M3S4RYKJcvudMc_OGdR0yvJhTV-ovI3s,2319
|
|
148
148
|
pylegend/utils/__init__.py,sha256=LXTDJSDmHQXtnMDZouhZp9IZQVpY6ONkINbUYjtnMkE,578
|
|
149
149
|
pylegend/utils/class_utils.py,sha256=t4PpF3jAXS_D6p9TqlSppryNYNOuy5C-kbKn2Kgb4QU,973
|
|
150
|
-
pylegend-0.
|
|
151
|
-
pylegend-0.
|
|
152
|
-
pylegend-0.
|
|
153
|
-
pylegend-0.
|
|
154
|
-
pylegend-0.
|
|
155
|
-
pylegend-0.
|
|
150
|
+
pylegend-0.6.0.dist-info/LICENSE,sha256=AGR96_qQPZO66Gjqq4G6r_g670K35VtW-IobTAkmZJM,11343
|
|
151
|
+
pylegend-0.6.0.dist-info/LICENSE.spdx,sha256=i7TsBclLotUvMjx9vZ_6S8Pp0r4uknWGw1RwiKBBvQ4,207
|
|
152
|
+
pylegend-0.6.0.dist-info/METADATA,sha256=1r4OHJqsKLYtsVxZSmEF65vBQBnLSTcXhHTzkDmfrTU,4210
|
|
153
|
+
pylegend-0.6.0.dist-info/NOTICE,sha256=2Lr4FqiscyRI7-vyn7c2z-zqUw2p6x7upJyBvFKkHjk,167
|
|
154
|
+
pylegend-0.6.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
155
|
+
pylegend-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|