vtlengine 1.0__py3-none-any.whl → 1.0.1__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.
Potentially problematic release.
This version of vtlengine might be problematic. Click here for more details.
- vtlengine/API/_InternalApi.py +153 -100
- vtlengine/API/__init__.py +109 -67
- vtlengine/AST/ASTConstructor.py +188 -98
- vtlengine/AST/ASTConstructorModules/Expr.py +306 -200
- vtlengine/AST/ASTConstructorModules/ExprComponents.py +172 -102
- vtlengine/AST/ASTConstructorModules/Terminals.py +158 -95
- vtlengine/AST/ASTEncoders.py +1 -1
- vtlengine/AST/ASTTemplate.py +8 -9
- vtlengine/AST/ASTVisitor.py +8 -12
- vtlengine/AST/DAG/__init__.py +43 -35
- vtlengine/AST/DAG/_words.py +4 -4
- vtlengine/AST/Grammar/lexer.py +732 -142
- vtlengine/AST/Grammar/parser.py +2188 -826
- vtlengine/AST/Grammar/tokens.py +128 -128
- vtlengine/AST/VtlVisitor.py +7 -4
- vtlengine/AST/__init__.py +22 -11
- vtlengine/DataTypes/NumericTypesHandling.py +5 -4
- vtlengine/DataTypes/TimeHandling.py +194 -301
- vtlengine/DataTypes/__init__.py +304 -218
- vtlengine/Exceptions/__init__.py +52 -27
- vtlengine/Exceptions/messages.py +134 -62
- vtlengine/Interpreter/__init__.py +781 -487
- vtlengine/Model/__init__.py +165 -121
- vtlengine/Operators/Aggregation.py +156 -95
- vtlengine/Operators/Analytic.py +115 -59
- vtlengine/Operators/Assignment.py +7 -4
- vtlengine/Operators/Boolean.py +27 -32
- vtlengine/Operators/CastOperator.py +177 -131
- vtlengine/Operators/Clause.py +137 -99
- vtlengine/Operators/Comparison.py +148 -117
- vtlengine/Operators/Conditional.py +149 -98
- vtlengine/Operators/General.py +68 -47
- vtlengine/Operators/HROperators.py +91 -72
- vtlengine/Operators/Join.py +217 -118
- vtlengine/Operators/Numeric.py +89 -44
- vtlengine/Operators/RoleSetter.py +16 -15
- vtlengine/Operators/Set.py +61 -36
- vtlengine/Operators/String.py +213 -139
- vtlengine/Operators/Time.py +334 -216
- vtlengine/Operators/Validation.py +117 -76
- vtlengine/Operators/__init__.py +340 -213
- vtlengine/Utils/__init__.py +195 -40
- vtlengine/__init__.py +1 -1
- vtlengine/files/output/__init__.py +15 -6
- vtlengine/files/output/_time_period_representation.py +10 -9
- vtlengine/files/parser/__init__.py +77 -52
- vtlengine/files/parser/_rfc_dialect.py +6 -5
- vtlengine/files/parser/_time_checking.py +46 -37
- vtlengine-1.0.1.dist-info/METADATA +236 -0
- vtlengine-1.0.1.dist-info/RECORD +58 -0
- {vtlengine-1.0.dist-info → vtlengine-1.0.1.dist-info}/WHEEL +1 -1
- vtlengine-1.0.dist-info/METADATA +0 -104
- vtlengine-1.0.dist-info/RECORD +0 -58
- {vtlengine-1.0.dist-info → vtlengine-1.0.1.dist-info}/LICENSE.md +0 -0
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
from antlr4.tree.Tree import TerminalNodeImpl
|
|
2
2
|
|
|
3
|
-
from vtlengine.AST import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
from vtlengine.AST import (
|
|
4
|
+
Aggregation,
|
|
5
|
+
If,
|
|
6
|
+
BinOp,
|
|
7
|
+
UnaryOp,
|
|
8
|
+
ID,
|
|
9
|
+
ParamOp,
|
|
10
|
+
MulOp,
|
|
11
|
+
Constant,
|
|
12
|
+
ParamConstant,
|
|
13
|
+
TimeAggregation,
|
|
14
|
+
Identifier,
|
|
15
|
+
EvalOp,
|
|
16
|
+
VarID,
|
|
17
|
+
Analytic,
|
|
18
|
+
UDOCall,
|
|
19
|
+
)
|
|
7
20
|
from vtlengine.AST.ASTConstructorModules.Terminals import Terminals
|
|
8
21
|
from vtlengine.AST.Grammar.parser import Parser
|
|
9
22
|
from vtlengine.AST.VtlVisitor import VtlVisitor
|
|
@@ -14,26 +27,26 @@ class ExprComp(VtlVisitor):
|
|
|
14
27
|
"""______________________________________________________________________________________
|
|
15
28
|
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
ExprComponent Definition.
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
_______________________________________________________________________________________"""
|
|
20
33
|
|
|
21
34
|
def visitExprComponent(self, ctx: Parser.ExprComponentContext):
|
|
22
35
|
"""
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
exprComponent:
|
|
37
|
+
LPAREN exprComponent RPAREN # parenthesisExprComp # noqa E501
|
|
38
|
+
| functionsComponents # functionsExpressionComp # noqa E501
|
|
39
|
+
| op=(PLUS|MINUS|NOT) right=exprComponent # unaryExprComp # noqa E501
|
|
40
|
+
| left=exprComponent op=(MUL|DIV) right=exprComponent # arithmeticExprComp # noqa E501
|
|
41
|
+
| left=exprComponent op=(PLUS|MINUS|CONCAT) right=exprComponent # arithmeticExprOrConcatComp # noqa E501
|
|
42
|
+
| left=exprComponent comparisonOperand right=exprComponent # comparisonExprComp # noqa E501
|
|
43
|
+
| left=exprComponent op=(IN|NOT_IN)(lists|valueDomainID) # inNotInExprComp # noqa E501
|
|
44
|
+
| left=exprComponent op=AND right=exprComponent # booleanExprComp # noqa E501
|
|
45
|
+
| left=exprComponent op=(OR|XOR) right=exprComponent # booleanExprComp # noqa E501
|
|
46
|
+
| IF conditionalExpr=exprComponent THEN thenExpr=exprComponent ELSE elseExpr=exprComponent # ifExprComp # noqa E501
|
|
47
|
+
| constant # constantExprComp # noqa E501
|
|
48
|
+
| componentID # compId # noqa E501
|
|
49
|
+
;
|
|
37
50
|
"""
|
|
38
51
|
ctx_list = list(ctx.getChildren())
|
|
39
52
|
c = ctx_list[0]
|
|
@@ -85,9 +98,9 @@ class ExprComp(VtlVisitor):
|
|
|
85
98
|
return Terminals().visitComponentID(c)
|
|
86
99
|
token = c.children[0].getSymbol()
|
|
87
100
|
# check token text
|
|
88
|
-
has_scaped_char = token.text.find("
|
|
101
|
+
has_scaped_char = token.text.find("'") != -1
|
|
89
102
|
if has_scaped_char:
|
|
90
|
-
token.text = str(token.text.replace("
|
|
103
|
+
token.text = str(token.text.replace("'", ""))
|
|
91
104
|
var_id_node = VarID(token.text)
|
|
92
105
|
return var_id_node
|
|
93
106
|
|
|
@@ -170,14 +183,14 @@ class ExprComp(VtlVisitor):
|
|
|
170
183
|
elif isinstance(c, TerminalNodeImpl):
|
|
171
184
|
token = c.getSymbol()
|
|
172
185
|
opt = token.text
|
|
173
|
-
return ID(
|
|
186
|
+
return ID("OPTIONAL", opt)
|
|
174
187
|
|
|
175
|
-
"""
|
|
188
|
+
"""____________________________________________________________________________________
|
|
176
189
|
|
|
177
190
|
|
|
178
|
-
|
|
191
|
+
FunctionsComponents Definition.
|
|
179
192
|
|
|
180
|
-
|
|
193
|
+
_____________________________________________________________________________________"""
|
|
181
194
|
|
|
182
195
|
def visitFunctionsComponents(self, ctx: Parser.FunctionsComponentsContext):
|
|
183
196
|
"""
|
|
@@ -224,7 +237,7 @@ class ExprComp(VtlVisitor):
|
|
|
224
237
|
|
|
225
238
|
"""
|
|
226
239
|
-----------------------------------
|
|
227
|
-
Generic Functions Components
|
|
240
|
+
Generic Functions Components
|
|
228
241
|
-----------------------------------
|
|
229
242
|
"""
|
|
230
243
|
|
|
@@ -240,56 +253,74 @@ class ExprComp(VtlVisitor):
|
|
|
240
253
|
|
|
241
254
|
def visitCallComponent(self, ctx: Parser.CallComponentContext):
|
|
242
255
|
"""
|
|
243
|
-
callFunction: operatorID LPAREN (parameterComponent (COMMA parameterComponent)*)? RPAREN # callComponent
|
|
256
|
+
callFunction: operatorID LPAREN (parameterComponent (COMMA parameterComponent)*)? RPAREN # callComponent # noqa E501
|
|
244
257
|
"""
|
|
245
258
|
ctx_list = list(ctx.getChildren())
|
|
246
259
|
c = ctx_list[0]
|
|
247
260
|
|
|
248
261
|
op = Terminals().visitOperatorID(c)
|
|
249
|
-
param_nodes = [
|
|
250
|
-
|
|
262
|
+
param_nodes = [
|
|
263
|
+
self.visitParameterComponent(element)
|
|
264
|
+
for element in ctx_list
|
|
265
|
+
if isinstance(element, Parser.ParameterComponentContext)
|
|
266
|
+
]
|
|
251
267
|
|
|
252
268
|
return UDOCall(op=op, params=param_nodes)
|
|
253
269
|
|
|
254
270
|
def visitEvalAtomComponent(self, ctx: Parser.EvalAtomComponentContext):
|
|
255
271
|
"""
|
|
256
|
-
|
|
272
|
+
| EVAL LPAREN routineName LPAREN (componentID|scalarItem)? (COMMA (componentID|scalarItem))* RPAREN (LANGUAGE STRING_CONSTANT)? (RETURNS outputParameterTypeComponent)? RPAREN # evalAtomComponent # noqa E501
|
|
257
273
|
"""
|
|
258
274
|
ctx_list = list(ctx.getChildren())
|
|
259
275
|
|
|
260
276
|
routine_name = Terminals().visitRoutineName(ctx_list[2])
|
|
261
277
|
|
|
262
278
|
# Think of a way to maintain the order, for now its not necessary.
|
|
263
|
-
var_ids_nodes = [
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
279
|
+
var_ids_nodes = [
|
|
280
|
+
Terminals().visitVarID(varID)
|
|
281
|
+
for varID in ctx_list
|
|
282
|
+
if isinstance(varID, Parser.VarIDContext)
|
|
283
|
+
]
|
|
284
|
+
constant_nodes = [
|
|
285
|
+
Terminals().visitScalarItem(scalar)
|
|
286
|
+
for scalar in ctx_list
|
|
287
|
+
if isinstance(scalar, Parser.ScalarItemContext)
|
|
288
|
+
]
|
|
267
289
|
children_nodes = var_ids_nodes + constant_nodes
|
|
268
290
|
|
|
269
291
|
if len(children_nodes) > 1:
|
|
270
292
|
raise Exception("Only one operand is allowed in Eval")
|
|
271
293
|
|
|
272
294
|
# Reference manual says it is mandatory.
|
|
273
|
-
language_name = [
|
|
274
|
-
|
|
275
|
-
|
|
295
|
+
language_name = [
|
|
296
|
+
language
|
|
297
|
+
for language in ctx_list
|
|
298
|
+
if isinstance(language, TerminalNodeImpl)
|
|
299
|
+
and language.getSymbol().type == Parser.STRING_CONSTANT
|
|
300
|
+
]
|
|
276
301
|
if len(language_name) == 0:
|
|
277
302
|
# AST_ASTCONSTRUCTOR.12
|
|
278
|
-
raise SemanticError("1-4-2-1", option=
|
|
303
|
+
raise SemanticError("1-4-2-1", option="language")
|
|
279
304
|
# Reference manual says it is mandatory.
|
|
280
|
-
output_node = [
|
|
281
|
-
|
|
282
|
-
|
|
305
|
+
output_node = [
|
|
306
|
+
Terminals().visitOutputParameterTypeComponent(output)
|
|
307
|
+
for output in ctx_list
|
|
308
|
+
if isinstance(output, Parser.OutputParameterTypeComponentContext)
|
|
309
|
+
]
|
|
283
310
|
if len(output_node) == 0:
|
|
284
311
|
# AST_ASTCONSTRUCTOR.13
|
|
285
|
-
raise SemanticError("1-4-2-1", option=
|
|
312
|
+
raise SemanticError("1-4-2-1", option="output")
|
|
286
313
|
|
|
287
|
-
return EvalOp(
|
|
288
|
-
|
|
314
|
+
return EvalOp(
|
|
315
|
+
name=routine_name,
|
|
316
|
+
operands=children_nodes[0],
|
|
317
|
+
output=output_node[0],
|
|
318
|
+
language=language_name[0].getSymbol().text,
|
|
319
|
+
)
|
|
289
320
|
|
|
290
321
|
def visitCastExprComponent(self, ctx: Parser.CastExprComponentContext):
|
|
291
322
|
"""
|
|
292
|
-
|
|
323
|
+
| CAST LPAREN exprComponent COMMA (basicScalarType|valueDomainName) (COMMA STRING_CONSTANT)? RPAREN # castExprComponent # noqa E501
|
|
293
324
|
"""
|
|
294
325
|
ctx_list = list(ctx.getChildren())
|
|
295
326
|
c = ctx_list[0]
|
|
@@ -297,19 +328,30 @@ class ExprComp(VtlVisitor):
|
|
|
297
328
|
token = c.getSymbol()
|
|
298
329
|
|
|
299
330
|
op = token.text
|
|
300
|
-
expr_node = [
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
331
|
+
expr_node = [
|
|
332
|
+
self.visitExprComponent(expr)
|
|
333
|
+
for expr in ctx_list
|
|
334
|
+
if isinstance(expr, Parser.ExprComponentContext)
|
|
335
|
+
]
|
|
336
|
+
basic_scalar_type = [
|
|
337
|
+
Terminals().visitBasicScalarType(type_)
|
|
338
|
+
for type_ in ctx_list
|
|
339
|
+
if isinstance(type_, Parser.BasicScalarTypeContext)
|
|
340
|
+
]
|
|
341
|
+
|
|
342
|
+
[
|
|
343
|
+
Terminals().visitValueDomainName(valueD)
|
|
344
|
+
for valueD in ctx_list
|
|
345
|
+
if isinstance(valueD, Parser.ValueDomainNameContext)
|
|
346
|
+
]
|
|
307
347
|
|
|
308
348
|
if len(ctx_list) > 6:
|
|
309
|
-
param_node = [
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
349
|
+
param_node = [
|
|
350
|
+
ParamConstant("PARAM_CAST", str_.symbol.text.strip('"'))
|
|
351
|
+
for str_ in ctx_list
|
|
352
|
+
if isinstance(str_, TerminalNodeImpl)
|
|
353
|
+
and str_.getSymbol().type == Parser.STRING_CONSTANT
|
|
354
|
+
]
|
|
313
355
|
else:
|
|
314
356
|
param_node = []
|
|
315
357
|
|
|
@@ -330,13 +372,13 @@ class ExprComp(VtlVisitor):
|
|
|
330
372
|
if isinstance(c, Parser.ExprComponentContext):
|
|
331
373
|
return self.visitExprComponent(c)
|
|
332
374
|
elif isinstance(c, TerminalNodeImpl):
|
|
333
|
-
return ID(
|
|
375
|
+
return ID("OPTIONAL", c.getSymbol().text)
|
|
334
376
|
else:
|
|
335
377
|
raise NotImplementedError
|
|
336
378
|
|
|
337
379
|
"""
|
|
338
380
|
-----------------------------------
|
|
339
|
-
String Functions
|
|
381
|
+
String Functions
|
|
340
382
|
-----------------------------------
|
|
341
383
|
"""
|
|
342
384
|
|
|
@@ -370,8 +412,9 @@ class ExprComp(VtlVisitor):
|
|
|
370
412
|
|
|
371
413
|
token = c.getSymbol()
|
|
372
414
|
childrens = [expr for expr in ctx_list if isinstance(expr, Parser.ExprComponentContext)]
|
|
373
|
-
params = [
|
|
374
|
-
|
|
415
|
+
params = [
|
|
416
|
+
param for param in ctx_list if isinstance(param, Parser.OptionalExprComponentContext)
|
|
417
|
+
]
|
|
375
418
|
|
|
376
419
|
op_node = token.text
|
|
377
420
|
for children in childrens:
|
|
@@ -388,10 +431,16 @@ class ExprComp(VtlVisitor):
|
|
|
388
431
|
c = ctx_list[0]
|
|
389
432
|
|
|
390
433
|
token = c.getSymbol()
|
|
391
|
-
expressions = [
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
434
|
+
expressions = [
|
|
435
|
+
self.visitExprComponent(expr)
|
|
436
|
+
for expr in ctx_list
|
|
437
|
+
if isinstance(expr, Parser.ExprComponentContext)
|
|
438
|
+
]
|
|
439
|
+
params = [
|
|
440
|
+
self.visitOptionalExprComponent(param)
|
|
441
|
+
for param in ctx_list
|
|
442
|
+
if isinstance(param, Parser.OptionalExprComponentContext)
|
|
443
|
+
]
|
|
395
444
|
|
|
396
445
|
op_node = token.text
|
|
397
446
|
|
|
@@ -405,10 +454,16 @@ class ExprComp(VtlVisitor):
|
|
|
405
454
|
c = ctx_list[0]
|
|
406
455
|
|
|
407
456
|
token = c.getSymbol()
|
|
408
|
-
expressions = [
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
457
|
+
expressions = [
|
|
458
|
+
self.visitExprComponent(expr)
|
|
459
|
+
for expr in ctx_list
|
|
460
|
+
if isinstance(expr, Parser.ExprComponentContext)
|
|
461
|
+
]
|
|
462
|
+
params = [
|
|
463
|
+
self.visitOptionalExprComponent(param)
|
|
464
|
+
for param in ctx_list
|
|
465
|
+
if isinstance(param, Parser.OptionalExprComponentContext)
|
|
466
|
+
]
|
|
412
467
|
|
|
413
468
|
op_node = token.text
|
|
414
469
|
|
|
@@ -419,7 +474,7 @@ class ExprComp(VtlVisitor):
|
|
|
419
474
|
|
|
420
475
|
"""
|
|
421
476
|
-----------------------------------
|
|
422
|
-
Numeric Component Functions
|
|
477
|
+
Numeric Component Functions
|
|
423
478
|
-----------------------------------
|
|
424
479
|
"""
|
|
425
480
|
|
|
@@ -442,8 +497,9 @@ class ExprComp(VtlVisitor):
|
|
|
442
497
|
operand_node = self.visitExprComponent(ctx_list[2])
|
|
443
498
|
return UnaryOp(op_node, operand_node)
|
|
444
499
|
|
|
445
|
-
def visitUnaryWithOptionalNumericComponent(
|
|
446
|
-
|
|
500
|
+
def visitUnaryWithOptionalNumericComponent(
|
|
501
|
+
self, ctx: Parser.UnaryWithOptionalNumericComponentContext
|
|
502
|
+
):
|
|
447
503
|
ctx_list = list(ctx.getChildren())
|
|
448
504
|
c = ctx_list[0]
|
|
449
505
|
|
|
@@ -452,8 +508,9 @@ class ExprComp(VtlVisitor):
|
|
|
452
508
|
|
|
453
509
|
token = c.getSymbol()
|
|
454
510
|
childrens = [expr for expr in ctx_list if isinstance(expr, Parser.ExprComponentContext)]
|
|
455
|
-
params = [
|
|
456
|
-
|
|
511
|
+
params = [
|
|
512
|
+
param for param in ctx_list if isinstance(param, Parser.OptionalExprComponentContext)
|
|
513
|
+
]
|
|
457
514
|
|
|
458
515
|
op_node = token.text
|
|
459
516
|
for children in childrens:
|
|
@@ -478,7 +535,7 @@ class ExprComp(VtlVisitor):
|
|
|
478
535
|
|
|
479
536
|
"""
|
|
480
537
|
-----------------------------------
|
|
481
|
-
Time Functions
|
|
538
|
+
Time Functions
|
|
482
539
|
-----------------------------------
|
|
483
540
|
"""
|
|
484
541
|
|
|
@@ -506,8 +563,11 @@ class ExprComp(VtlVisitor):
|
|
|
506
563
|
c = ctx_list[0]
|
|
507
564
|
|
|
508
565
|
op = c.getSymbol().text
|
|
509
|
-
operand_node = [
|
|
510
|
-
|
|
566
|
+
operand_node = [
|
|
567
|
+
self.visitExprComponent(operand)
|
|
568
|
+
for operand in ctx_list
|
|
569
|
+
if isinstance(operand, Parser.ExprComponentContext)
|
|
570
|
+
]
|
|
511
571
|
|
|
512
572
|
if len(operand_node) == 0:
|
|
513
573
|
# AST_ASTCONSTRUCTOR.15
|
|
@@ -524,7 +584,7 @@ class ExprComp(VtlVisitor):
|
|
|
524
584
|
|
|
525
585
|
op = c.getSymbol().text
|
|
526
586
|
left_node = self.visitExprComponent(ctx_list[2])
|
|
527
|
-
right_node = Constant(
|
|
587
|
+
right_node = Constant("INTEGER_CONSTANT", int(ctx_list[4].getSymbol().text))
|
|
528
588
|
|
|
529
589
|
return BinOp(left=left_node, op=op, right=right_node)
|
|
530
590
|
|
|
@@ -539,7 +599,7 @@ class ExprComp(VtlVisitor):
|
|
|
539
599
|
children_node = [self.visitExprComponent(ctx_list[2])]
|
|
540
600
|
|
|
541
601
|
if len(ctx_list) > 4:
|
|
542
|
-
param_constant_node = [ParamConstant(
|
|
602
|
+
param_constant_node = [ParamConstant("PARAM_TIMESERIES", ctx_list[4].getSymbol().text)]
|
|
543
603
|
else:
|
|
544
604
|
param_constant_node = []
|
|
545
605
|
|
|
@@ -547,8 +607,8 @@ class ExprComp(VtlVisitor):
|
|
|
547
607
|
|
|
548
608
|
def visitTimeAggAtomComponent(self, ctx: Parser.TimeAggAtomComponentContext):
|
|
549
609
|
"""
|
|
550
|
-
TIME_AGG LPAREN periodIndTo=STRING_CONSTANT (COMMA periodIndFrom=(STRING_CONSTANT| OPTIONAL ))?
|
|
551
|
-
(COMMA op=optionalExprComponent)? (COMMA (FIRST|LAST))? RPAREN # timeAggAtomComponent;
|
|
610
|
+
TIME_AGG LPAREN periodIndTo=STRING_CONSTANT (COMMA periodIndFrom=(STRING_CONSTANT| OPTIONAL ))? # noqa E501
|
|
611
|
+
(COMMA op=optionalExprComponent)? (COMMA (FIRST|LAST))? RPAREN # timeAggAtomComponent; # noqa E501
|
|
552
612
|
"""
|
|
553
613
|
ctx_list = list(ctx.getChildren())
|
|
554
614
|
c = ctx_list[0]
|
|
@@ -561,9 +621,12 @@ class ExprComp(VtlVisitor):
|
|
|
561
621
|
# raise SemanticError("periodIndFrom is not allowed in Time_agg")
|
|
562
622
|
period_from = str(ctx.periodIndFrom.text)[1:-1]
|
|
563
623
|
|
|
564
|
-
conf = [
|
|
565
|
-
|
|
566
|
-
|
|
624
|
+
conf = [
|
|
625
|
+
str_.getSymbol().text
|
|
626
|
+
for str_ in ctx_list
|
|
627
|
+
if isinstance(str_, TerminalNodeImpl)
|
|
628
|
+
and str_.getSymbol().type in [Parser.FIRST, Parser.LAST]
|
|
629
|
+
]
|
|
567
630
|
|
|
568
631
|
if len(conf) == 0:
|
|
569
632
|
conf = None
|
|
@@ -582,8 +645,9 @@ class ExprComp(VtlVisitor):
|
|
|
582
645
|
if operand_node is None:
|
|
583
646
|
# AST_ASTCONSTRUCTOR.17
|
|
584
647
|
raise SemanticError("1-4-2-2")
|
|
585
|
-
return TimeAggregation(
|
|
586
|
-
|
|
648
|
+
return TimeAggregation(
|
|
649
|
+
op=op, operand=operand_node, period_to=period_to, period_from=period_from, conf=conf
|
|
650
|
+
)
|
|
587
651
|
|
|
588
652
|
def visitCurrentDateAtomComponent(self, ctx: Parser.CurrentDateAtomComponentContext):
|
|
589
653
|
c = list(ctx.getChildren())[0]
|
|
@@ -591,12 +655,13 @@ class ExprComp(VtlVisitor):
|
|
|
591
655
|
|
|
592
656
|
"""
|
|
593
657
|
-----------------------------------
|
|
594
|
-
Conditional Functions
|
|
658
|
+
Conditional Functions
|
|
595
659
|
-----------------------------------
|
|
596
660
|
"""
|
|
597
661
|
|
|
598
|
-
def visitConditionalFunctionsComponents(
|
|
599
|
-
|
|
662
|
+
def visitConditionalFunctionsComponents(
|
|
663
|
+
self, ctx: Parser.ConditionalFunctionsComponentsContext
|
|
664
|
+
):
|
|
600
665
|
if isinstance(ctx, Parser.NvlAtomComponentContext):
|
|
601
666
|
return self.visitNvlAtomComponent(ctx)
|
|
602
667
|
else:
|
|
@@ -615,7 +680,7 @@ class ExprComp(VtlVisitor):
|
|
|
615
680
|
|
|
616
681
|
"""
|
|
617
682
|
-----------------------------------
|
|
618
|
-
Comparison Components Functions
|
|
683
|
+
Comparison Components Functions
|
|
619
684
|
-----------------------------------
|
|
620
685
|
"""
|
|
621
686
|
|
|
@@ -664,7 +729,7 @@ class ExprComp(VtlVisitor):
|
|
|
664
729
|
|
|
665
730
|
"""
|
|
666
731
|
-----------------------------------
|
|
667
|
-
Aggregate Components Functions
|
|
732
|
+
Aggregate Components Functions
|
|
668
733
|
-----------------------------------
|
|
669
734
|
"""
|
|
670
735
|
|
|
@@ -689,7 +754,7 @@ class ExprComp(VtlVisitor):
|
|
|
689
754
|
|
|
690
755
|
"""
|
|
691
756
|
-----------------------------------
|
|
692
|
-
|
|
757
|
+
Analytic Components Functions
|
|
693
758
|
-----------------------------------
|
|
694
759
|
"""
|
|
695
760
|
|
|
@@ -729,8 +794,9 @@ class ExprComp(VtlVisitor):
|
|
|
729
794
|
else:
|
|
730
795
|
raise NotImplementedError
|
|
731
796
|
|
|
732
|
-
return Analytic(
|
|
733
|
-
|
|
797
|
+
return Analytic(
|
|
798
|
+
op=op_node, operand=operand, partition_by=partition_by, order_by=order_by, window=params
|
|
799
|
+
)
|
|
734
800
|
|
|
735
801
|
def visitLagOrLeadAnComponent(self, ctx: Parser.LagOrLeadAnComponentContext):
|
|
736
802
|
ctx_list = list(ctx.getChildren())
|
|
@@ -749,8 +815,9 @@ class ExprComp(VtlVisitor):
|
|
|
749
815
|
elif isinstance(c, Parser.OrderByClauseContext):
|
|
750
816
|
order_by = Terminals().visitOrderByClause(c)
|
|
751
817
|
continue
|
|
752
|
-
elif isinstance(c, Parser.SignedIntegerContext) or isinstance(
|
|
753
|
-
|
|
818
|
+
elif isinstance(c, Parser.SignedIntegerContext) or isinstance(
|
|
819
|
+
c, Parser.ScalarItemContext
|
|
820
|
+
):
|
|
754
821
|
if params is None:
|
|
755
822
|
params = []
|
|
756
823
|
if isinstance(c, Parser.SignedIntegerContext):
|
|
@@ -759,8 +826,9 @@ class ExprComp(VtlVisitor):
|
|
|
759
826
|
params.append(Terminals().visitScalarItem(c))
|
|
760
827
|
continue
|
|
761
828
|
|
|
762
|
-
return Analytic(
|
|
763
|
-
|
|
829
|
+
return Analytic(
|
|
830
|
+
op=op_node, operand=operand, partition_by=partition_by, order_by=order_by, params=params
|
|
831
|
+
)
|
|
764
832
|
|
|
765
833
|
def visitRankAnComponent(self, ctx: Parser.RankAnComponentContext):
|
|
766
834
|
ctx_list = list(ctx.getChildren())
|
|
@@ -778,8 +846,9 @@ class ExprComp(VtlVisitor):
|
|
|
778
846
|
order_by = Terminals().visitOrderByClause(c)
|
|
779
847
|
continue
|
|
780
848
|
|
|
781
|
-
return Analytic(
|
|
782
|
-
|
|
849
|
+
return Analytic(
|
|
850
|
+
op=op_node, operand=None, partition_by=partition_by, order_by=order_by, window=None
|
|
851
|
+
)
|
|
783
852
|
|
|
784
853
|
def visitRatioToReportAnComponent(self, ctx: Parser.RatioToReportAnComponentContext):
|
|
785
854
|
ctx_list = list(ctx.getChildren())
|
|
@@ -792,5 +861,6 @@ class ExprComp(VtlVisitor):
|
|
|
792
861
|
|
|
793
862
|
partition_by = Terminals().visitPartitionByClause(ctx_list[5])
|
|
794
863
|
|
|
795
|
-
return Analytic(
|
|
796
|
-
|
|
864
|
+
return Analytic(
|
|
865
|
+
op=op_node, operand=operand, partition_by=partition_by, order_by=order_by, window=params
|
|
866
|
+
)
|