pylegend 0.5.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/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 +84 -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 +8 -16
- pylegend/core/language/shared/operations/string_operation_expressions.py +43 -26
- pylegend/core/language/shared/operations/unary_expression.py +16 -1
- {pylegend-0.5.0.dist-info → pylegend-0.6.0.dist-info}/METADATA +1 -1
- {pylegend-0.5.0.dist-info → pylegend-0.6.0.dist-info}/RECORD +17 -17
- {pylegend-0.5.0.dist-info → pylegend-0.6.0.dist-info}/LICENSE +0 -0
- {pylegend-0.5.0.dist-info → pylegend-0.6.0.dist-info}/LICENSE.spdx +0 -0
- {pylegend-0.5.0.dist-info → pylegend-0.6.0.dist-info}/NOTICE +0 -0
- {pylegend-0.5.0.dist-info → pylegend-0.6.0.dist-info}/WHEEL +0 -0
|
@@ -24,8 +24,7 @@ __all__ = [
|
|
|
24
24
|
def generate_pure_functional_call(
|
|
25
25
|
func: str,
|
|
26
26
|
params: PyLegendList[str],
|
|
27
|
-
force_prefix: bool = False
|
|
28
|
-
auto_map: bool = False
|
|
27
|
+
force_prefix: bool = False
|
|
29
28
|
) -> str:
|
|
30
29
|
should_prefix = force_prefix or (len(params) == 0)
|
|
31
30
|
|
|
@@ -39,13 +38,6 @@ def generate_pure_functional_call(
|
|
|
39
38
|
else:
|
|
40
39
|
updated_params.append(param)
|
|
41
40
|
|
|
42
|
-
if auto_map and len(updated_params) == 1:
|
|
43
|
-
return f"{params[0]}->map(op | {generate_pure_functional_call(func, ['$op'], force_prefix, False)})"
|
|
44
|
-
|
|
45
|
-
if auto_map and len(updated_params) == 2:
|
|
46
|
-
new_params = ['$op'] + [updated_params[1]]
|
|
47
|
-
return f"{params[0]}->map(op | {generate_pure_functional_call(func, new_params, force_prefix, False)})"
|
|
48
|
-
|
|
49
41
|
if should_prefix:
|
|
50
42
|
return f"{func}({', '.join(updated_params)})"
|
|
51
43
|
else:
|
|
@@ -43,6 +43,9 @@ class PyLegendBinaryExpression(PyLegendExpression, metaclass=ABCMeta):
|
|
|
43
43
|
Expression
|
|
44
44
|
]
|
|
45
45
|
__to_pure_func: PyLegendCallable[[str, str, FrameToPureConfig], str]
|
|
46
|
+
__non_nullable: bool
|
|
47
|
+
__first_operand_needs_to_be_non_nullable: bool
|
|
48
|
+
__second_operand_needs_to_be_non_nullable: bool
|
|
46
49
|
|
|
47
50
|
def __init__(
|
|
48
51
|
self,
|
|
@@ -52,12 +55,18 @@ class PyLegendBinaryExpression(PyLegendExpression, metaclass=ABCMeta):
|
|
|
52
55
|
[Expression, Expression, PyLegendDict[str, QuerySpecification], FrameToSqlConfig],
|
|
53
56
|
Expression
|
|
54
57
|
],
|
|
55
|
-
to_pure_func: PyLegendCallable[[str, str, FrameToPureConfig], str]
|
|
58
|
+
to_pure_func: PyLegendCallable[[str, str, FrameToPureConfig], str],
|
|
59
|
+
non_nullable: bool = False,
|
|
60
|
+
first_operand_needs_to_be_non_nullable: bool = False,
|
|
61
|
+
second_operand_needs_to_be_non_nullable: bool = False,
|
|
56
62
|
) -> None:
|
|
57
63
|
self.__operand1 = operand1
|
|
58
64
|
self.__operand2 = operand2
|
|
59
65
|
self.__to_sql_func = to_sql_func
|
|
60
66
|
self.__to_pure_func = to_pure_func
|
|
67
|
+
self.__non_nullable = non_nullable
|
|
68
|
+
self.__first_operand_needs_to_be_non_nullable = first_operand_needs_to_be_non_nullable
|
|
69
|
+
self.__second_operand_needs_to_be_non_nullable = second_operand_needs_to_be_non_nullable
|
|
61
70
|
|
|
62
71
|
def to_sql_expression(
|
|
63
72
|
self,
|
|
@@ -75,27 +84,18 @@ class PyLegendBinaryExpression(PyLegendExpression, metaclass=ABCMeta):
|
|
|
75
84
|
|
|
76
85
|
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
77
86
|
op1_expr = self.__operand1.to_pure_expression(config)
|
|
87
|
+
if self.__first_operand_needs_to_be_non_nullable:
|
|
88
|
+
op1_expr = (
|
|
89
|
+
op1_expr if self.__operand1.is_non_nullable() else
|
|
90
|
+
f"toOne({op1_expr[1:-1] if expr_has_matching_start_and_end_parentheses(op1_expr) else op1_expr})"
|
|
91
|
+
)
|
|
78
92
|
op2_expr = self.__operand2.to_pure_expression(config)
|
|
93
|
+
if self.__second_operand_needs_to_be_non_nullable:
|
|
94
|
+
op2_expr = (
|
|
95
|
+
op2_expr if self.__operand2.is_non_nullable() else
|
|
96
|
+
f"toOne({op2_expr[1:-1] if expr_has_matching_start_and_end_parentheses(op2_expr) else op2_expr})"
|
|
97
|
+
)
|
|
79
98
|
return self.__to_pure_func(op1_expr, op2_expr, config)
|
|
80
99
|
|
|
81
|
-
def
|
|
82
|
-
|
|
83
|
-
op1_expr = (
|
|
84
|
-
op1_expr if self.__operand1.is_non_nullable() else
|
|
85
|
-
f"toOne({op1_expr[1:-1] if expr_has_matching_start_and_end_parentheses(op1_expr) else op1_expr})"
|
|
86
|
-
)
|
|
87
|
-
op2_expr = self.__operand2.to_pure_expression(config)
|
|
88
|
-
op2_expr = (
|
|
89
|
-
op2_expr if self.__operand2.is_non_nullable() else
|
|
90
|
-
f"toOne({op2_expr[1:-1] if expr_has_matching_start_and_end_parentheses(op2_expr) else op2_expr})"
|
|
91
|
-
)
|
|
92
|
-
return self.__to_pure_func(op1_expr, op2_expr, config)
|
|
93
|
-
|
|
94
|
-
def to_pure_expression_with_to_one_on_second_operand(self, config: FrameToPureConfig) -> str:
|
|
95
|
-
op1_expr = self.__operand1.to_pure_expression(config)
|
|
96
|
-
op2_expr = self.__operand2.to_pure_expression(config)
|
|
97
|
-
op2_expr = (
|
|
98
|
-
op2_expr if self.__operand2.is_non_nullable() else
|
|
99
|
-
f"toOne({op2_expr[1:-1] if expr_has_matching_start_and_end_parentheses(op2_expr) else op2_expr})"
|
|
100
|
-
)
|
|
101
|
-
return self.__to_pure_func(op1_expr, op2_expr, config)
|
|
100
|
+
def is_non_nullable(self) -> bool:
|
|
101
|
+
return self.__non_nullable
|
|
@@ -19,6 +19,7 @@ from pylegend._typing import (
|
|
|
19
19
|
from pylegend.core.language.shared.expression import (
|
|
20
20
|
PyLegendExpressionBooleanReturn,
|
|
21
21
|
)
|
|
22
|
+
from pylegend.core.language.shared.helpers import generate_pure_functional_call
|
|
22
23
|
from pylegend.core.language.shared.operations.binary_expression import PyLegendBinaryExpression
|
|
23
24
|
from pylegend.core.language.shared.operations.unary_expression import PyLegendUnaryExpression
|
|
24
25
|
from pylegend.core.sql.metamodel import (
|
|
@@ -61,15 +62,12 @@ class PyLegendBooleanOrExpression(PyLegendBinaryExpression, PyLegendExpressionBo
|
|
|
61
62
|
operand1,
|
|
62
63
|
operand2,
|
|
63
64
|
PyLegendBooleanOrExpression.__to_sql_func,
|
|
64
|
-
PyLegendBooleanOrExpression.__to_pure_func
|
|
65
|
+
PyLegendBooleanOrExpression.__to_pure_func,
|
|
66
|
+
non_nullable=True,
|
|
67
|
+
first_operand_needs_to_be_non_nullable=True,
|
|
68
|
+
second_operand_needs_to_be_non_nullable=True
|
|
65
69
|
)
|
|
66
70
|
|
|
67
|
-
def is_non_nullable(self) -> bool:
|
|
68
|
-
return True
|
|
69
|
-
|
|
70
|
-
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
71
|
-
return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
|
|
72
|
-
|
|
73
71
|
|
|
74
72
|
class PyLegendBooleanAndExpression(PyLegendBinaryExpression, PyLegendExpressionBooleanReturn):
|
|
75
73
|
|
|
@@ -93,15 +91,12 @@ class PyLegendBooleanAndExpression(PyLegendBinaryExpression, PyLegendExpressionB
|
|
|
93
91
|
operand1,
|
|
94
92
|
operand2,
|
|
95
93
|
PyLegendBooleanAndExpression.__to_sql_func,
|
|
96
|
-
PyLegendBooleanAndExpression.__to_pure_func
|
|
94
|
+
PyLegendBooleanAndExpression.__to_pure_func,
|
|
95
|
+
non_nullable=True,
|
|
96
|
+
first_operand_needs_to_be_non_nullable=True,
|
|
97
|
+
second_operand_needs_to_be_non_nullable=True
|
|
97
98
|
)
|
|
98
99
|
|
|
99
|
-
def is_non_nullable(self) -> bool:
|
|
100
|
-
return True
|
|
101
|
-
|
|
102
|
-
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
103
|
-
return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
|
|
104
|
-
|
|
105
100
|
|
|
106
101
|
class PyLegendBooleanNotExpression(PyLegendUnaryExpression, PyLegendExpressionBooleanReturn):
|
|
107
102
|
|
|
@@ -115,7 +110,7 @@ class PyLegendBooleanNotExpression(PyLegendUnaryExpression, PyLegendExpressionBo
|
|
|
115
110
|
|
|
116
111
|
@staticmethod
|
|
117
112
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
118
|
-
return
|
|
113
|
+
return generate_pure_functional_call("not", [op_expr])
|
|
119
114
|
|
|
120
115
|
def __init__(self, operand: PyLegendExpressionBooleanReturn) -> None:
|
|
121
116
|
PyLegendExpressionBooleanReturn.__init__(self)
|
|
@@ -123,5 +118,7 @@ class PyLegendBooleanNotExpression(PyLegendUnaryExpression, PyLegendExpressionBo
|
|
|
123
118
|
self,
|
|
124
119
|
operand,
|
|
125
120
|
PyLegendBooleanNotExpression.__to_sql_func,
|
|
126
|
-
PyLegendBooleanNotExpression.__to_pure_func
|
|
121
|
+
PyLegendBooleanNotExpression.__to_pure_func,
|
|
122
|
+
non_nullable=True,
|
|
123
|
+
operand_needs_to_be_non_nullable=True,
|
|
127
124
|
)
|
|
@@ -106,7 +106,7 @@ class PyLegendFirstDayOfYearExpression(PyLegendUnaryExpression, PyLegendExpressi
|
|
|
106
106
|
|
|
107
107
|
@staticmethod
|
|
108
108
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
109
|
-
return generate_pure_functional_call("firstDayOfYear", [op_expr]
|
|
109
|
+
return generate_pure_functional_call("firstDayOfYear", [op_expr])
|
|
110
110
|
|
|
111
111
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
112
112
|
PyLegendExpressionDateReturn.__init__(self)
|
|
@@ -114,7 +114,9 @@ class PyLegendFirstDayOfYearExpression(PyLegendUnaryExpression, PyLegendExpressi
|
|
|
114
114
|
self,
|
|
115
115
|
operand,
|
|
116
116
|
PyLegendFirstDayOfYearExpression.__to_sql_func,
|
|
117
|
-
PyLegendFirstDayOfYearExpression.__to_pure_func
|
|
117
|
+
PyLegendFirstDayOfYearExpression.__to_pure_func,
|
|
118
|
+
non_nullable=True,
|
|
119
|
+
operand_needs_to_be_non_nullable=True
|
|
118
120
|
)
|
|
119
121
|
|
|
120
122
|
|
|
@@ -130,7 +132,7 @@ class PyLegendFirstDayOfQuarterExpression(PyLegendUnaryExpression, PyLegendExpre
|
|
|
130
132
|
|
|
131
133
|
@staticmethod
|
|
132
134
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
133
|
-
return generate_pure_functional_call("firstDayOfQuarter", [op_expr]
|
|
135
|
+
return generate_pure_functional_call("firstDayOfQuarter", [op_expr])
|
|
134
136
|
|
|
135
137
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
136
138
|
PyLegendExpressionDateReturn.__init__(self)
|
|
@@ -138,7 +140,9 @@ class PyLegendFirstDayOfQuarterExpression(PyLegendUnaryExpression, PyLegendExpre
|
|
|
138
140
|
self,
|
|
139
141
|
operand,
|
|
140
142
|
PyLegendFirstDayOfQuarterExpression.__to_sql_func,
|
|
141
|
-
PyLegendFirstDayOfQuarterExpression.__to_pure_func
|
|
143
|
+
PyLegendFirstDayOfQuarterExpression.__to_pure_func,
|
|
144
|
+
non_nullable=True,
|
|
145
|
+
operand_needs_to_be_non_nullable=True
|
|
142
146
|
)
|
|
143
147
|
|
|
144
148
|
|
|
@@ -154,7 +158,7 @@ class PyLegendFirstDayOfMonthExpression(PyLegendUnaryExpression, PyLegendExpress
|
|
|
154
158
|
|
|
155
159
|
@staticmethod
|
|
156
160
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
157
|
-
return generate_pure_functional_call("firstDayOfMonth", [op_expr]
|
|
161
|
+
return generate_pure_functional_call("firstDayOfMonth", [op_expr])
|
|
158
162
|
|
|
159
163
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
160
164
|
PyLegendExpressionDateReturn.__init__(self)
|
|
@@ -162,7 +166,9 @@ class PyLegendFirstDayOfMonthExpression(PyLegendUnaryExpression, PyLegendExpress
|
|
|
162
166
|
self,
|
|
163
167
|
operand,
|
|
164
168
|
PyLegendFirstDayOfMonthExpression.__to_sql_func,
|
|
165
|
-
PyLegendFirstDayOfMonthExpression.__to_pure_func
|
|
169
|
+
PyLegendFirstDayOfMonthExpression.__to_pure_func,
|
|
170
|
+
non_nullable=True,
|
|
171
|
+
operand_needs_to_be_non_nullable=True
|
|
166
172
|
)
|
|
167
173
|
|
|
168
174
|
|
|
@@ -178,7 +184,7 @@ class PyLegendFirstDayOfWeekExpression(PyLegendUnaryExpression, PyLegendExpressi
|
|
|
178
184
|
|
|
179
185
|
@staticmethod
|
|
180
186
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
181
|
-
return generate_pure_functional_call("firstDayOfWeek", [op_expr]
|
|
187
|
+
return generate_pure_functional_call("firstDayOfWeek", [op_expr])
|
|
182
188
|
|
|
183
189
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
184
190
|
PyLegendExpressionDateReturn.__init__(self)
|
|
@@ -186,7 +192,9 @@ class PyLegendFirstDayOfWeekExpression(PyLegendUnaryExpression, PyLegendExpressi
|
|
|
186
192
|
self,
|
|
187
193
|
operand,
|
|
188
194
|
PyLegendFirstDayOfWeekExpression.__to_sql_func,
|
|
189
|
-
PyLegendFirstDayOfWeekExpression.__to_pure_func
|
|
195
|
+
PyLegendFirstDayOfWeekExpression.__to_pure_func,
|
|
196
|
+
non_nullable=True,
|
|
197
|
+
operand_needs_to_be_non_nullable=True
|
|
190
198
|
)
|
|
191
199
|
|
|
192
200
|
|
|
@@ -202,7 +210,7 @@ class PyLegendFirstHourOfDayExpression(PyLegendUnaryExpression, PyLegendExpressi
|
|
|
202
210
|
|
|
203
211
|
@staticmethod
|
|
204
212
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
205
|
-
return generate_pure_functional_call("firstHourOfDay", [op_expr]
|
|
213
|
+
return generate_pure_functional_call("firstHourOfDay", [op_expr])
|
|
206
214
|
|
|
207
215
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
208
216
|
PyLegendExpressionDateTimeReturn.__init__(self)
|
|
@@ -210,7 +218,9 @@ class PyLegendFirstHourOfDayExpression(PyLegendUnaryExpression, PyLegendExpressi
|
|
|
210
218
|
self,
|
|
211
219
|
operand,
|
|
212
220
|
PyLegendFirstHourOfDayExpression.__to_sql_func,
|
|
213
|
-
PyLegendFirstHourOfDayExpression.__to_pure_func
|
|
221
|
+
PyLegendFirstHourOfDayExpression.__to_pure_func,
|
|
222
|
+
non_nullable=True,
|
|
223
|
+
operand_needs_to_be_non_nullable=True
|
|
214
224
|
)
|
|
215
225
|
|
|
216
226
|
|
|
@@ -226,7 +236,7 @@ class PyLegendFirstMinuteOfHourExpression(PyLegendUnaryExpression, PyLegendExpre
|
|
|
226
236
|
|
|
227
237
|
@staticmethod
|
|
228
238
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
229
|
-
return generate_pure_functional_call("firstMinuteOfHour", [op_expr]
|
|
239
|
+
return generate_pure_functional_call("firstMinuteOfHour", [op_expr])
|
|
230
240
|
|
|
231
241
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
232
242
|
PyLegendExpressionDateTimeReturn.__init__(self)
|
|
@@ -234,7 +244,9 @@ class PyLegendFirstMinuteOfHourExpression(PyLegendUnaryExpression, PyLegendExpre
|
|
|
234
244
|
self,
|
|
235
245
|
operand,
|
|
236
246
|
PyLegendFirstMinuteOfHourExpression.__to_sql_func,
|
|
237
|
-
PyLegendFirstMinuteOfHourExpression.__to_pure_func
|
|
247
|
+
PyLegendFirstMinuteOfHourExpression.__to_pure_func,
|
|
248
|
+
non_nullable=True,
|
|
249
|
+
operand_needs_to_be_non_nullable=True
|
|
238
250
|
)
|
|
239
251
|
|
|
240
252
|
|
|
@@ -250,7 +262,7 @@ class PyLegendFirstSecondOfMinuteExpression(PyLegendUnaryExpression, PyLegendExp
|
|
|
250
262
|
|
|
251
263
|
@staticmethod
|
|
252
264
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
253
|
-
return generate_pure_functional_call("firstSecondOfMinute", [op_expr]
|
|
265
|
+
return generate_pure_functional_call("firstSecondOfMinute", [op_expr])
|
|
254
266
|
|
|
255
267
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
256
268
|
PyLegendExpressionDateTimeReturn.__init__(self)
|
|
@@ -258,7 +270,9 @@ class PyLegendFirstSecondOfMinuteExpression(PyLegendUnaryExpression, PyLegendExp
|
|
|
258
270
|
self,
|
|
259
271
|
operand,
|
|
260
272
|
PyLegendFirstSecondOfMinuteExpression.__to_sql_func,
|
|
261
|
-
PyLegendFirstSecondOfMinuteExpression.__to_pure_func
|
|
273
|
+
PyLegendFirstSecondOfMinuteExpression.__to_pure_func,
|
|
274
|
+
non_nullable=True,
|
|
275
|
+
operand_needs_to_be_non_nullable=True
|
|
262
276
|
)
|
|
263
277
|
|
|
264
278
|
|
|
@@ -274,7 +288,7 @@ class PyLegendFirstMillisecondOfSecondExpression(PyLegendUnaryExpression, PyLege
|
|
|
274
288
|
|
|
275
289
|
@staticmethod
|
|
276
290
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
277
|
-
return generate_pure_functional_call("firstMillisecondOfSecond", [op_expr]
|
|
291
|
+
return generate_pure_functional_call("firstMillisecondOfSecond", [op_expr])
|
|
278
292
|
|
|
279
293
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
280
294
|
PyLegendExpressionDateTimeReturn.__init__(self)
|
|
@@ -282,7 +296,9 @@ class PyLegendFirstMillisecondOfSecondExpression(PyLegendUnaryExpression, PyLege
|
|
|
282
296
|
self,
|
|
283
297
|
operand,
|
|
284
298
|
PyLegendFirstMillisecondOfSecondExpression.__to_sql_func,
|
|
285
|
-
PyLegendFirstMillisecondOfSecondExpression.__to_pure_func
|
|
299
|
+
PyLegendFirstMillisecondOfSecondExpression.__to_pure_func,
|
|
300
|
+
non_nullable=True,
|
|
301
|
+
operand_needs_to_be_non_nullable=True
|
|
286
302
|
)
|
|
287
303
|
|
|
288
304
|
|
|
@@ -298,7 +314,7 @@ class PyLegendYearExpression(PyLegendUnaryExpression, PyLegendExpressionIntegerR
|
|
|
298
314
|
|
|
299
315
|
@staticmethod
|
|
300
316
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
301
|
-
return generate_pure_functional_call("year", [op_expr]
|
|
317
|
+
return generate_pure_functional_call("year", [op_expr])
|
|
302
318
|
|
|
303
319
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
304
320
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -306,7 +322,9 @@ class PyLegendYearExpression(PyLegendUnaryExpression, PyLegendExpressionIntegerR
|
|
|
306
322
|
self,
|
|
307
323
|
operand,
|
|
308
324
|
PyLegendYearExpression.__to_sql_func,
|
|
309
|
-
PyLegendYearExpression.__to_pure_func
|
|
325
|
+
PyLegendYearExpression.__to_pure_func,
|
|
326
|
+
non_nullable=True,
|
|
327
|
+
operand_needs_to_be_non_nullable=True
|
|
310
328
|
)
|
|
311
329
|
|
|
312
330
|
|
|
@@ -322,7 +340,7 @@ class PyLegendQuarterExpression(PyLegendUnaryExpression, PyLegendExpressionInteg
|
|
|
322
340
|
|
|
323
341
|
@staticmethod
|
|
324
342
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
325
|
-
return generate_pure_functional_call("quarter", [op_expr]
|
|
343
|
+
return generate_pure_functional_call("quarter", [op_expr])
|
|
326
344
|
|
|
327
345
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
328
346
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -330,7 +348,9 @@ class PyLegendQuarterExpression(PyLegendUnaryExpression, PyLegendExpressionInteg
|
|
|
330
348
|
self,
|
|
331
349
|
operand,
|
|
332
350
|
PyLegendQuarterExpression.__to_sql_func,
|
|
333
|
-
PyLegendQuarterExpression.__to_pure_func
|
|
351
|
+
PyLegendQuarterExpression.__to_pure_func,
|
|
352
|
+
non_nullable=True,
|
|
353
|
+
operand_needs_to_be_non_nullable=True
|
|
334
354
|
)
|
|
335
355
|
|
|
336
356
|
|
|
@@ -346,7 +366,7 @@ class PyLegendMonthExpression(PyLegendUnaryExpression, PyLegendExpressionInteger
|
|
|
346
366
|
|
|
347
367
|
@staticmethod
|
|
348
368
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
349
|
-
return generate_pure_functional_call("month", [op_expr]
|
|
369
|
+
return generate_pure_functional_call("month", [op_expr])
|
|
350
370
|
|
|
351
371
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
352
372
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -354,7 +374,9 @@ class PyLegendMonthExpression(PyLegendUnaryExpression, PyLegendExpressionInteger
|
|
|
354
374
|
self,
|
|
355
375
|
operand,
|
|
356
376
|
PyLegendMonthExpression.__to_sql_func,
|
|
357
|
-
PyLegendMonthExpression.__to_pure_func
|
|
377
|
+
PyLegendMonthExpression.__to_pure_func,
|
|
378
|
+
non_nullable=True,
|
|
379
|
+
operand_needs_to_be_non_nullable=True
|
|
358
380
|
)
|
|
359
381
|
|
|
360
382
|
|
|
@@ -370,7 +392,7 @@ class PyLegendWeekOfYearExpression(PyLegendUnaryExpression, PyLegendExpressionIn
|
|
|
370
392
|
|
|
371
393
|
@staticmethod
|
|
372
394
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
373
|
-
return generate_pure_functional_call("weekOfYear", [op_expr]
|
|
395
|
+
return generate_pure_functional_call("weekOfYear", [op_expr])
|
|
374
396
|
|
|
375
397
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
376
398
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -378,7 +400,9 @@ class PyLegendWeekOfYearExpression(PyLegendUnaryExpression, PyLegendExpressionIn
|
|
|
378
400
|
self,
|
|
379
401
|
operand,
|
|
380
402
|
PyLegendWeekOfYearExpression.__to_sql_func,
|
|
381
|
-
PyLegendWeekOfYearExpression.__to_pure_func
|
|
403
|
+
PyLegendWeekOfYearExpression.__to_pure_func,
|
|
404
|
+
non_nullable=True,
|
|
405
|
+
operand_needs_to_be_non_nullable=True
|
|
382
406
|
)
|
|
383
407
|
|
|
384
408
|
|
|
@@ -394,7 +418,7 @@ class PyLegendDayOfYearExpression(PyLegendUnaryExpression, PyLegendExpressionInt
|
|
|
394
418
|
|
|
395
419
|
@staticmethod
|
|
396
420
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
397
|
-
return generate_pure_functional_call("dayOfYear", [op_expr]
|
|
421
|
+
return generate_pure_functional_call("dayOfYear", [op_expr])
|
|
398
422
|
|
|
399
423
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
400
424
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -402,7 +426,9 @@ class PyLegendDayOfYearExpression(PyLegendUnaryExpression, PyLegendExpressionInt
|
|
|
402
426
|
self,
|
|
403
427
|
operand,
|
|
404
428
|
PyLegendDayOfYearExpression.__to_sql_func,
|
|
405
|
-
PyLegendDayOfYearExpression.__to_pure_func
|
|
429
|
+
PyLegendDayOfYearExpression.__to_pure_func,
|
|
430
|
+
non_nullable=True,
|
|
431
|
+
operand_needs_to_be_non_nullable=True
|
|
406
432
|
)
|
|
407
433
|
|
|
408
434
|
|
|
@@ -418,7 +444,7 @@ class PyLegendDayOfMonthExpression(PyLegendUnaryExpression, PyLegendExpressionIn
|
|
|
418
444
|
|
|
419
445
|
@staticmethod
|
|
420
446
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
421
|
-
return generate_pure_functional_call("dayOfMonth", [op_expr]
|
|
447
|
+
return generate_pure_functional_call("dayOfMonth", [op_expr])
|
|
422
448
|
|
|
423
449
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
424
450
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -426,7 +452,9 @@ class PyLegendDayOfMonthExpression(PyLegendUnaryExpression, PyLegendExpressionIn
|
|
|
426
452
|
self,
|
|
427
453
|
operand,
|
|
428
454
|
PyLegendDayOfMonthExpression.__to_sql_func,
|
|
429
|
-
PyLegendDayOfMonthExpression.__to_pure_func
|
|
455
|
+
PyLegendDayOfMonthExpression.__to_pure_func,
|
|
456
|
+
non_nullable=True,
|
|
457
|
+
operand_needs_to_be_non_nullable=True
|
|
430
458
|
)
|
|
431
459
|
|
|
432
460
|
|
|
@@ -442,7 +470,7 @@ class PyLegendDayOfWeekExpression(PyLegendUnaryExpression, PyLegendExpressionInt
|
|
|
442
470
|
|
|
443
471
|
@staticmethod
|
|
444
472
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
445
|
-
return generate_pure_functional_call("dayOfWeekNumber", [op_expr]
|
|
473
|
+
return generate_pure_functional_call("dayOfWeekNumber", [op_expr])
|
|
446
474
|
|
|
447
475
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
448
476
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -450,7 +478,9 @@ class PyLegendDayOfWeekExpression(PyLegendUnaryExpression, PyLegendExpressionInt
|
|
|
450
478
|
self,
|
|
451
479
|
operand,
|
|
452
480
|
PyLegendDayOfWeekExpression.__to_sql_func,
|
|
453
|
-
PyLegendDayOfWeekExpression.__to_pure_func
|
|
481
|
+
PyLegendDayOfWeekExpression.__to_pure_func,
|
|
482
|
+
non_nullable=True,
|
|
483
|
+
operand_needs_to_be_non_nullable=True
|
|
454
484
|
)
|
|
455
485
|
|
|
456
486
|
|
|
@@ -466,7 +496,7 @@ class PyLegendHourExpression(PyLegendUnaryExpression, PyLegendExpressionIntegerR
|
|
|
466
496
|
|
|
467
497
|
@staticmethod
|
|
468
498
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
469
|
-
return generate_pure_functional_call("hour", [op_expr]
|
|
499
|
+
return generate_pure_functional_call("hour", [op_expr])
|
|
470
500
|
|
|
471
501
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
472
502
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -474,7 +504,9 @@ class PyLegendHourExpression(PyLegendUnaryExpression, PyLegendExpressionIntegerR
|
|
|
474
504
|
self,
|
|
475
505
|
operand,
|
|
476
506
|
PyLegendHourExpression.__to_sql_func,
|
|
477
|
-
PyLegendHourExpression.__to_pure_func
|
|
507
|
+
PyLegendHourExpression.__to_pure_func,
|
|
508
|
+
non_nullable=True,
|
|
509
|
+
operand_needs_to_be_non_nullable=True
|
|
478
510
|
)
|
|
479
511
|
|
|
480
512
|
|
|
@@ -490,7 +522,7 @@ class PyLegendMinuteExpression(PyLegendUnaryExpression, PyLegendExpressionIntege
|
|
|
490
522
|
|
|
491
523
|
@staticmethod
|
|
492
524
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
493
|
-
return generate_pure_functional_call("minute", [op_expr]
|
|
525
|
+
return generate_pure_functional_call("minute", [op_expr])
|
|
494
526
|
|
|
495
527
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
496
528
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -498,7 +530,9 @@ class PyLegendMinuteExpression(PyLegendUnaryExpression, PyLegendExpressionIntege
|
|
|
498
530
|
self,
|
|
499
531
|
operand,
|
|
500
532
|
PyLegendMinuteExpression.__to_sql_func,
|
|
501
|
-
PyLegendMinuteExpression.__to_pure_func
|
|
533
|
+
PyLegendMinuteExpression.__to_pure_func,
|
|
534
|
+
non_nullable=True,
|
|
535
|
+
operand_needs_to_be_non_nullable=True
|
|
502
536
|
)
|
|
503
537
|
|
|
504
538
|
|
|
@@ -514,7 +548,7 @@ class PyLegendSecondExpression(PyLegendUnaryExpression, PyLegendExpressionIntege
|
|
|
514
548
|
|
|
515
549
|
@staticmethod
|
|
516
550
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
517
|
-
return generate_pure_functional_call("second", [op_expr]
|
|
551
|
+
return generate_pure_functional_call("second", [op_expr])
|
|
518
552
|
|
|
519
553
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
520
554
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -522,7 +556,9 @@ class PyLegendSecondExpression(PyLegendUnaryExpression, PyLegendExpressionIntege
|
|
|
522
556
|
self,
|
|
523
557
|
operand,
|
|
524
558
|
PyLegendSecondExpression.__to_sql_func,
|
|
525
|
-
PyLegendSecondExpression.__to_pure_func
|
|
559
|
+
PyLegendSecondExpression.__to_pure_func,
|
|
560
|
+
non_nullable=True,
|
|
561
|
+
operand_needs_to_be_non_nullable=True
|
|
526
562
|
)
|
|
527
563
|
|
|
528
564
|
|
|
@@ -538,7 +574,7 @@ class PyLegendEpochExpression(PyLegendUnaryExpression, PyLegendExpressionInteger
|
|
|
538
574
|
|
|
539
575
|
@staticmethod
|
|
540
576
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
541
|
-
return generate_pure_functional_call("toEpochValue", [op_expr]
|
|
577
|
+
return generate_pure_functional_call("toEpochValue", [op_expr])
|
|
542
578
|
|
|
543
579
|
def __init__(self, operand: PyLegendExpressionDateReturn) -> None:
|
|
544
580
|
PyLegendExpressionIntegerReturn.__init__(self)
|
|
@@ -546,7 +582,9 @@ class PyLegendEpochExpression(PyLegendUnaryExpression, PyLegendExpressionInteger
|
|
|
546
582
|
self,
|
|
547
583
|
operand,
|
|
548
584
|
PyLegendEpochExpression.__to_sql_func,
|
|
549
|
-
PyLegendEpochExpression.__to_pure_func
|
|
585
|
+
PyLegendEpochExpression.__to_pure_func,
|
|
586
|
+
non_nullable=True,
|
|
587
|
+
operand_needs_to_be_non_nullable=True
|
|
550
588
|
)
|
|
551
589
|
|
|
552
590
|
|
|
@@ -568,7 +606,8 @@ class PyLegendTodayExpression(PyLegendNullaryExpression, PyLegendExpressionStric
|
|
|
568
606
|
PyLegendNullaryExpression.__init__(
|
|
569
607
|
self,
|
|
570
608
|
PyLegendTodayExpression.__to_sql_func,
|
|
571
|
-
PyLegendTodayExpression.__to_pure_func
|
|
609
|
+
PyLegendTodayExpression.__to_pure_func,
|
|
610
|
+
non_nullable=True
|
|
572
611
|
)
|
|
573
612
|
|
|
574
613
|
|
|
@@ -590,7 +629,8 @@ class PyLegendNowExpression(PyLegendNullaryExpression, PyLegendExpressionDateTim
|
|
|
590
629
|
PyLegendNullaryExpression.__init__(
|
|
591
630
|
self,
|
|
592
631
|
PyLegendNowExpression.__to_sql_func,
|
|
593
|
-
PyLegendNowExpression.__to_pure_func
|
|
632
|
+
PyLegendNowExpression.__to_pure_func,
|
|
633
|
+
non_nullable=True
|
|
594
634
|
)
|
|
595
635
|
|
|
596
636
|
|
|
@@ -609,7 +649,7 @@ class PyLegendDatePartExpression(PyLegendUnaryExpression, PyLegendExpressionStri
|
|
|
609
649
|
return generate_pure_functional_call(
|
|
610
650
|
"cast",
|
|
611
651
|
[
|
|
612
|
-
generate_pure_functional_call("datePart", [op_expr]
|
|
652
|
+
generate_pure_functional_call("datePart", [op_expr]),
|
|
613
653
|
"@StrictDate",
|
|
614
654
|
]
|
|
615
655
|
)
|
|
@@ -620,7 +660,9 @@ class PyLegendDatePartExpression(PyLegendUnaryExpression, PyLegendExpressionStri
|
|
|
620
660
|
self,
|
|
621
661
|
operand,
|
|
622
662
|
PyLegendDatePartExpression.__to_sql_func,
|
|
623
|
-
PyLegendDatePartExpression.__to_pure_func
|
|
663
|
+
PyLegendDatePartExpression.__to_pure_func,
|
|
664
|
+
non_nullable=True,
|
|
665
|
+
operand_needs_to_be_non_nullable=True
|
|
624
666
|
)
|
|
625
667
|
|
|
626
668
|
|
|
@@ -67,15 +67,12 @@ class PyLegendFloatAddExpression(PyLegendBinaryExpression, PyLegendExpressionFlo
|
|
|
67
67
|
operand1,
|
|
68
68
|
operand2,
|
|
69
69
|
PyLegendFloatAddExpression.__to_sql_func,
|
|
70
|
-
PyLegendFloatAddExpression.__to_pure_func
|
|
70
|
+
PyLegendFloatAddExpression.__to_pure_func,
|
|
71
|
+
non_nullable=True,
|
|
72
|
+
first_operand_needs_to_be_non_nullable=True,
|
|
73
|
+
second_operand_needs_to_be_non_nullable=True
|
|
71
74
|
)
|
|
72
75
|
|
|
73
|
-
def is_non_nullable(self) -> bool:
|
|
74
|
-
return True
|
|
75
|
-
|
|
76
|
-
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
77
|
-
return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
|
|
78
|
-
|
|
79
76
|
|
|
80
77
|
class PyLegendFloatSubtractExpression(PyLegendBinaryExpression, PyLegendExpressionFloatReturn):
|
|
81
78
|
|
|
@@ -99,15 +96,12 @@ class PyLegendFloatSubtractExpression(PyLegendBinaryExpression, PyLegendExpressi
|
|
|
99
96
|
operand1,
|
|
100
97
|
operand2,
|
|
101
98
|
PyLegendFloatSubtractExpression.__to_sql_func,
|
|
102
|
-
PyLegendFloatSubtractExpression.__to_pure_func
|
|
99
|
+
PyLegendFloatSubtractExpression.__to_pure_func,
|
|
100
|
+
non_nullable=True,
|
|
101
|
+
first_operand_needs_to_be_non_nullable=True,
|
|
102
|
+
second_operand_needs_to_be_non_nullable=True
|
|
103
103
|
)
|
|
104
104
|
|
|
105
|
-
def is_non_nullable(self) -> bool:
|
|
106
|
-
return True
|
|
107
|
-
|
|
108
|
-
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
109
|
-
return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
|
|
110
|
-
|
|
111
105
|
|
|
112
106
|
class PyLegendFloatMultiplyExpression(PyLegendBinaryExpression, PyLegendExpressionFloatReturn):
|
|
113
107
|
|
|
@@ -131,15 +125,12 @@ class PyLegendFloatMultiplyExpression(PyLegendBinaryExpression, PyLegendExpressi
|
|
|
131
125
|
operand1,
|
|
132
126
|
operand2,
|
|
133
127
|
PyLegendFloatMultiplyExpression.__to_sql_func,
|
|
134
|
-
PyLegendFloatMultiplyExpression.__to_pure_func
|
|
128
|
+
PyLegendFloatMultiplyExpression.__to_pure_func,
|
|
129
|
+
non_nullable=True,
|
|
130
|
+
first_operand_needs_to_be_non_nullable=True,
|
|
131
|
+
second_operand_needs_to_be_non_nullable=True
|
|
135
132
|
)
|
|
136
133
|
|
|
137
|
-
def is_non_nullable(self) -> bool:
|
|
138
|
-
return True
|
|
139
|
-
|
|
140
|
-
def to_pure_expression(self, config: FrameToPureConfig) -> str:
|
|
141
|
-
return PyLegendBinaryExpression.to_pure_expression_with_to_one_on_both_operands(self, config)
|
|
142
|
-
|
|
143
134
|
|
|
144
135
|
class PyLegendFloatAbsoluteExpression(PyLegendUnaryExpression, PyLegendExpressionFloatReturn):
|
|
145
136
|
|
|
@@ -153,7 +144,7 @@ class PyLegendFloatAbsoluteExpression(PyLegendUnaryExpression, PyLegendExpressio
|
|
|
153
144
|
|
|
154
145
|
@staticmethod
|
|
155
146
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
156
|
-
return generate_pure_functional_call("abs", [op_expr]
|
|
147
|
+
return generate_pure_functional_call("abs", [op_expr])
|
|
157
148
|
|
|
158
149
|
def __init__(self, operand: PyLegendExpressionFloatReturn) -> None:
|
|
159
150
|
PyLegendExpressionFloatReturn.__init__(self)
|
|
@@ -161,7 +152,9 @@ class PyLegendFloatAbsoluteExpression(PyLegendUnaryExpression, PyLegendExpressio
|
|
|
161
152
|
self,
|
|
162
153
|
operand,
|
|
163
154
|
PyLegendFloatAbsoluteExpression.__to_sql_func,
|
|
164
|
-
PyLegendFloatAbsoluteExpression.__to_pure_func
|
|
155
|
+
PyLegendFloatAbsoluteExpression.__to_pure_func,
|
|
156
|
+
non_nullable=True,
|
|
157
|
+
operand_needs_to_be_non_nullable=True
|
|
165
158
|
)
|
|
166
159
|
|
|
167
160
|
|
|
@@ -177,7 +170,7 @@ class PyLegendFloatNegativeExpression(PyLegendUnaryExpression, PyLegendExpressio
|
|
|
177
170
|
|
|
178
171
|
@staticmethod
|
|
179
172
|
def __to_pure_func(op_expr: str, config: FrameToPureConfig) -> str:
|
|
180
|
-
return generate_pure_functional_call("minus", [op_expr]
|
|
173
|
+
return generate_pure_functional_call("minus", [op_expr])
|
|
181
174
|
|
|
182
175
|
def __init__(self, operand: PyLegendExpressionFloatReturn) -> None:
|
|
183
176
|
PyLegendExpressionFloatReturn.__init__(self)
|
|
@@ -185,5 +178,7 @@ class PyLegendFloatNegativeExpression(PyLegendUnaryExpression, PyLegendExpressio
|
|
|
185
178
|
self,
|
|
186
179
|
operand,
|
|
187
180
|
PyLegendFloatNegativeExpression.__to_sql_func,
|
|
188
|
-
PyLegendFloatNegativeExpression.__to_pure_func
|
|
181
|
+
PyLegendFloatNegativeExpression.__to_pure_func,
|
|
182
|
+
non_nullable=True,
|
|
183
|
+
operand_needs_to_be_non_nullable=True,
|
|
189
184
|
)
|