vtlengine 1.0.3rc3__py3-none-any.whl → 1.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 +288 -61
- vtlengine/API/__init__.py +269 -71
- vtlengine/API/data/schema/json_schema_2.1.json +116 -0
- vtlengine/AST/ASTComment.py +56 -0
- vtlengine/AST/ASTConstructor.py +76 -22
- vtlengine/AST/ASTConstructorModules/Expr.py +238 -120
- vtlengine/AST/ASTConstructorModules/ExprComponents.py +126 -61
- vtlengine/AST/ASTConstructorModules/Terminals.py +97 -42
- vtlengine/AST/ASTConstructorModules/__init__.py +50 -0
- vtlengine/AST/ASTEncoders.py +5 -1
- vtlengine/AST/ASTString.py +608 -0
- vtlengine/AST/ASTTemplate.py +28 -2
- vtlengine/AST/DAG/__init__.py +10 -4
- vtlengine/AST/Grammar/lexer.py +0 -1
- vtlengine/AST/Grammar/parser.py +185 -440
- vtlengine/AST/VtlVisitor.py +0 -1
- vtlengine/AST/__init__.py +127 -14
- vtlengine/DataTypes/TimeHandling.py +50 -15
- vtlengine/DataTypes/__init__.py +79 -7
- vtlengine/Exceptions/__init__.py +3 -5
- vtlengine/Exceptions/messages.py +74 -105
- vtlengine/Interpreter/__init__.py +136 -46
- vtlengine/Model/__init__.py +14 -11
- vtlengine/Operators/Aggregation.py +17 -9
- vtlengine/Operators/Analytic.py +64 -20
- vtlengine/Operators/Assignment.py +0 -1
- vtlengine/Operators/CastOperator.py +44 -44
- vtlengine/Operators/Clause.py +16 -10
- vtlengine/Operators/Comparison.py +20 -12
- vtlengine/Operators/Conditional.py +47 -15
- vtlengine/Operators/General.py +9 -4
- vtlengine/Operators/HROperators.py +4 -14
- vtlengine/Operators/Join.py +15 -14
- vtlengine/Operators/Numeric.py +32 -26
- vtlengine/Operators/RoleSetter.py +6 -2
- vtlengine/Operators/Set.py +12 -8
- vtlengine/Operators/String.py +9 -9
- vtlengine/Operators/Time.py +145 -124
- vtlengine/Operators/Validation.py +10 -4
- vtlengine/Operators/__init__.py +56 -69
- vtlengine/Utils/__init__.py +55 -1
- vtlengine/__extras_check.py +17 -0
- vtlengine/__init__.py +2 -2
- vtlengine/files/output/__init__.py +2 -1
- vtlengine/files/output/_time_period_representation.py +2 -1
- vtlengine/files/parser/__init__.py +52 -46
- vtlengine/files/parser/_time_checking.py +4 -4
- {vtlengine-1.0.3rc3.dist-info → vtlengine-1.1.dist-info}/METADATA +21 -17
- vtlengine-1.1.dist-info/RECORD +61 -0
- {vtlengine-1.0.3rc3.dist-info → vtlengine-1.1.dist-info}/WHEEL +1 -1
- vtlengine/DataTypes/NumericTypesHandling.py +0 -38
- vtlengine-1.0.3rc3.dist-info/RECORD +0 -58
- {vtlengine-1.0.3rc3.dist-info → vtlengine-1.1.dist-info}/LICENSE.md +0 -0
|
@@ -14,11 +14,13 @@ from vtlengine.AST import (
|
|
|
14
14
|
MulOp,
|
|
15
15
|
ParamConstant,
|
|
16
16
|
ParamOp,
|
|
17
|
+
ParFunction,
|
|
17
18
|
TimeAggregation,
|
|
18
19
|
UDOCall,
|
|
19
20
|
UnaryOp,
|
|
20
21
|
VarID,
|
|
21
22
|
)
|
|
23
|
+
from vtlengine.AST.ASTConstructorModules import extract_token_info
|
|
22
24
|
from vtlengine.AST.ASTConstructorModules.Terminals import Terminals
|
|
23
25
|
from vtlengine.AST.Grammar.parser import Parser
|
|
24
26
|
from vtlengine.AST.VtlVisitor import VtlVisitor
|
|
@@ -31,7 +33,8 @@ class ExprComp(VtlVisitor):
|
|
|
31
33
|
|
|
32
34
|
ExprComponent Definition.
|
|
33
35
|
|
|
34
|
-
_______________________________________________________________________________________
|
|
36
|
+
_______________________________________________________________________________________
|
|
37
|
+
"""
|
|
35
38
|
|
|
36
39
|
def visitExprComponent(self, ctx: Parser.ExprComponentContext):
|
|
37
40
|
"""
|
|
@@ -49,7 +52,7 @@ class ExprComp(VtlVisitor):
|
|
|
49
52
|
| constant # constantExprComp
|
|
50
53
|
| componentID # compId
|
|
51
54
|
;
|
|
52
|
-
"""
|
|
55
|
+
""" # noqa E501
|
|
53
56
|
ctx_list = list(ctx.getChildren())
|
|
54
57
|
c = ctx_list[0]
|
|
55
58
|
|
|
@@ -107,7 +110,7 @@ class ExprComp(VtlVisitor):
|
|
|
107
110
|
has_scaped_char = token.text.find("'") != -1
|
|
108
111
|
if has_scaped_char:
|
|
109
112
|
token.text = str(token.text.replace("'", ""))
|
|
110
|
-
var_id_node = VarID(token.text)
|
|
113
|
+
var_id_node = VarID(value=token.text, **extract_token_info(ctx))
|
|
111
114
|
return var_id_node
|
|
112
115
|
|
|
113
116
|
else:
|
|
@@ -123,7 +126,7 @@ class ExprComp(VtlVisitor):
|
|
|
123
126
|
op = ctx_list[1].getSymbol().text
|
|
124
127
|
right_node = self.visitExprComponent(ctx_list[2])
|
|
125
128
|
|
|
126
|
-
bin_op_node = BinOp(left_node, op, right_node)
|
|
129
|
+
bin_op_node = BinOp(left=left_node, op=op, right=right_node, **extract_token_info(ctx))
|
|
127
130
|
|
|
128
131
|
return bin_op_node
|
|
129
132
|
|
|
@@ -147,7 +150,7 @@ class ExprComp(VtlVisitor):
|
|
|
147
150
|
right_node = Terminals().visitValueDomainID(ctx_list[2])
|
|
148
151
|
else:
|
|
149
152
|
raise NotImplementedError
|
|
150
|
-
bin_op_node = BinOp(left_node, op, right_node)
|
|
153
|
+
bin_op_node = BinOp(left=left_node, op=op, right=right_node, **extract_token_info(ctx))
|
|
151
154
|
|
|
152
155
|
return bin_op_node
|
|
153
156
|
|
|
@@ -155,14 +158,15 @@ class ExprComp(VtlVisitor):
|
|
|
155
158
|
return self.bin_op_creator_comp(ctx)
|
|
156
159
|
|
|
157
160
|
def visitParenthesisExprComp(self, ctx: Parser.ParenthesisExprContext):
|
|
158
|
-
|
|
161
|
+
operand = self.visitExprComponent(list(ctx.getChildren())[1])
|
|
162
|
+
return ParFunction(operand=operand, **extract_token_info(ctx))
|
|
159
163
|
|
|
160
164
|
def visitUnaryExprComp(self, ctx: Parser.UnaryExprContext):
|
|
161
165
|
c_list = list(ctx.getChildren())
|
|
162
166
|
op = c_list[0].getSymbol().text
|
|
163
167
|
right = self.visitExprComponent(c_list[1])
|
|
164
168
|
|
|
165
|
-
return UnaryOp(op, right)
|
|
169
|
+
return UnaryOp(op=op, operand=right, **extract_token_info(ctx))
|
|
166
170
|
|
|
167
171
|
def visitIfExprComp(self, ctx: Parser.IfExprCompContext):
|
|
168
172
|
ctx_list = list(ctx.getChildren())
|
|
@@ -171,7 +175,12 @@ class ExprComp(VtlVisitor):
|
|
|
171
175
|
then_op_node = self.visitExprComponent(ctx_list[3])
|
|
172
176
|
else_op_node = self.visitExprComponent(ctx_list[5])
|
|
173
177
|
|
|
174
|
-
if_node = If(
|
|
178
|
+
if_node = If(
|
|
179
|
+
condition=condition_node,
|
|
180
|
+
thenOp=then_op_node,
|
|
181
|
+
elseOp=else_op_node,
|
|
182
|
+
**extract_token_info(ctx),
|
|
183
|
+
)
|
|
175
184
|
|
|
176
185
|
return if_node
|
|
177
186
|
|
|
@@ -188,10 +197,12 @@ class ExprComp(VtlVisitor):
|
|
|
188
197
|
for i in range(0, len(ctx_list), 4):
|
|
189
198
|
condition = self.visitExprComponent(ctx_list[i + 1])
|
|
190
199
|
thenOp = self.visitExprComponent(ctx_list[i + 3])
|
|
191
|
-
case_obj = CaseObj(
|
|
200
|
+
case_obj = CaseObj(
|
|
201
|
+
condition=condition, thenOp=thenOp, **extract_token_info(ctx_list[i + 1])
|
|
202
|
+
)
|
|
192
203
|
cases.append(case_obj)
|
|
193
204
|
|
|
194
|
-
case_node = Case(cases, else_node)
|
|
205
|
+
case_node = Case(cases=cases, elseOp=else_node, **extract_token_info(ctx))
|
|
195
206
|
|
|
196
207
|
return case_node
|
|
197
208
|
|
|
@@ -209,7 +220,7 @@ class ExprComp(VtlVisitor):
|
|
|
209
220
|
elif isinstance(c, TerminalNodeImpl):
|
|
210
221
|
token = c.getSymbol()
|
|
211
222
|
opt = token.text
|
|
212
|
-
return ID("OPTIONAL", opt)
|
|
223
|
+
return ID(type_="OPTIONAL", value=opt, **extract_token_info(ctx))
|
|
213
224
|
|
|
214
225
|
"""____________________________________________________________________________________
|
|
215
226
|
|
|
@@ -280,7 +291,7 @@ class ExprComp(VtlVisitor):
|
|
|
280
291
|
def visitCallComponent(self, ctx: Parser.CallComponentContext):
|
|
281
292
|
"""
|
|
282
293
|
callFunction: operatorID LPAREN (parameterComponent (COMMA parameterComponent)*)? RPAREN # callComponent
|
|
283
|
-
"""
|
|
294
|
+
""" # noqa E501
|
|
284
295
|
ctx_list = list(ctx.getChildren())
|
|
285
296
|
c = ctx_list[0]
|
|
286
297
|
|
|
@@ -291,12 +302,12 @@ class ExprComp(VtlVisitor):
|
|
|
291
302
|
if isinstance(element, Parser.ParameterComponentContext)
|
|
292
303
|
]
|
|
293
304
|
|
|
294
|
-
return UDOCall(op=op, params=param_nodes)
|
|
305
|
+
return UDOCall(op=op, params=param_nodes, **extract_token_info(ctx))
|
|
295
306
|
|
|
296
307
|
def visitEvalAtomComponent(self, ctx: Parser.EvalAtomComponentContext):
|
|
297
308
|
"""
|
|
298
309
|
| EVAL LPAREN routineName LPAREN (componentID|scalarItem)? (COMMA (componentID|scalarItem))* RPAREN (LANGUAGE STRING_CONSTANT)? (RETURNS outputParameterTypeComponent)? RPAREN # evalAtomComponent
|
|
299
|
-
"""
|
|
310
|
+
""" # noqa E501
|
|
300
311
|
ctx_list = list(ctx.getChildren())
|
|
301
312
|
|
|
302
313
|
routine_name = Terminals().visitRoutineName(ctx_list[2])
|
|
@@ -342,12 +353,13 @@ class ExprComp(VtlVisitor):
|
|
|
342
353
|
operands=children_nodes[0],
|
|
343
354
|
output=output_node[0],
|
|
344
355
|
language=language_name[0].getSymbol().text,
|
|
356
|
+
**extract_token_info(ctx),
|
|
345
357
|
)
|
|
346
358
|
|
|
347
359
|
def visitCastExprComponent(self, ctx: Parser.CastExprComponentContext):
|
|
348
360
|
"""
|
|
349
361
|
| CAST LPAREN exprComponent COMMA (basicScalarType|valueDomainName) (COMMA STRING_CONSTANT)? RPAREN # castExprComponent
|
|
350
|
-
"""
|
|
362
|
+
""" # noqa E501
|
|
351
363
|
ctx_list = list(ctx.getChildren())
|
|
352
364
|
c = ctx_list[0]
|
|
353
365
|
|
|
@@ -373,7 +385,11 @@ class ExprComp(VtlVisitor):
|
|
|
373
385
|
|
|
374
386
|
if len(ctx_list) > 6:
|
|
375
387
|
param_node = [
|
|
376
|
-
ParamConstant(
|
|
388
|
+
ParamConstant(
|
|
389
|
+
type_="PARAM_CAST",
|
|
390
|
+
value=str_.symbol.text.strip('"'),
|
|
391
|
+
**extract_token_info(str_.getSymbol()),
|
|
392
|
+
)
|
|
377
393
|
for str_ in ctx_list
|
|
378
394
|
if isinstance(str_, TerminalNodeImpl)
|
|
379
395
|
and str_.getSymbol().type == Parser.STRING_CONSTANT
|
|
@@ -384,21 +400,22 @@ class ExprComp(VtlVisitor):
|
|
|
384
400
|
if len(basic_scalar_type) == 1:
|
|
385
401
|
children_nodes = expr_node + basic_scalar_type
|
|
386
402
|
|
|
387
|
-
return ParamOp(
|
|
403
|
+
return ParamOp(
|
|
404
|
+
op=op, children=children_nodes, params=param_node, **extract_token_info(ctx)
|
|
405
|
+
)
|
|
388
406
|
|
|
389
407
|
else:
|
|
390
408
|
# AST_ASTCONSTRUCTOR.14
|
|
391
409
|
raise NotImplementedError
|
|
392
410
|
|
|
393
411
|
def visitParameterComponent(self, ctx: Parser.ParameterComponentContext):
|
|
394
|
-
|
|
395
412
|
ctx_list = list(ctx.getChildren())
|
|
396
413
|
c = ctx_list[0]
|
|
397
414
|
|
|
398
415
|
if isinstance(c, Parser.ExprComponentContext):
|
|
399
416
|
return self.visitExprComponent(c)
|
|
400
417
|
elif isinstance(c, TerminalNodeImpl):
|
|
401
|
-
return ID("OPTIONAL", c.getSymbol().text)
|
|
418
|
+
return ID(type_="OPTIONAL", value=c.getSymbol().text, **extract_token_info(ctx))
|
|
402
419
|
else:
|
|
403
420
|
raise NotImplementedError
|
|
404
421
|
|
|
@@ -427,7 +444,7 @@ class ExprComp(VtlVisitor):
|
|
|
427
444
|
token = c.getSymbol()
|
|
428
445
|
op_node = token.text
|
|
429
446
|
operand_node = self.visitExprComponent(ctx_list[2])
|
|
430
|
-
return UnaryOp(op_node, operand_node)
|
|
447
|
+
return UnaryOp(op=op_node, operand=operand_node, **extract_token_info(ctx))
|
|
431
448
|
|
|
432
449
|
def visitSubstrAtomComponent(self, ctx: Parser.SubstrAtomComponentContext):
|
|
433
450
|
ctx_list = list(ctx.getChildren())
|
|
@@ -450,7 +467,9 @@ class ExprComp(VtlVisitor):
|
|
|
450
467
|
for param in params:
|
|
451
468
|
params_nodes.append(self.visitOptionalExprComponent(param))
|
|
452
469
|
|
|
453
|
-
return ParamOp(
|
|
470
|
+
return ParamOp(
|
|
471
|
+
op=op_node, children=children_nodes, params=params_nodes, **extract_token_info(ctx)
|
|
472
|
+
)
|
|
454
473
|
|
|
455
474
|
def visitReplaceAtomComponent(self, ctx: Parser.ReplaceAtomComponentContext):
|
|
456
475
|
ctx_list = list(ctx.getChildren())
|
|
@@ -473,7 +492,9 @@ class ExprComp(VtlVisitor):
|
|
|
473
492
|
children_nodes = [expressions[0]]
|
|
474
493
|
params_nodes = [expressions[1]] + params
|
|
475
494
|
|
|
476
|
-
return ParamOp(
|
|
495
|
+
return ParamOp(
|
|
496
|
+
op=op_node, children=children_nodes, params=params_nodes, **extract_token_info(ctx)
|
|
497
|
+
)
|
|
477
498
|
|
|
478
499
|
def visitInstrAtomComponent(self, ctx: Parser.InstrAtomComponentContext):
|
|
479
500
|
ctx_list = list(ctx.getChildren())
|
|
@@ -496,7 +517,9 @@ class ExprComp(VtlVisitor):
|
|
|
496
517
|
children_nodes = [expressions[0]]
|
|
497
518
|
params_nodes = [expressions[1]] + params
|
|
498
519
|
|
|
499
|
-
return ParamOp(
|
|
520
|
+
return ParamOp(
|
|
521
|
+
op=op_node, children=children_nodes, params=params_nodes, **extract_token_info(ctx)
|
|
522
|
+
)
|
|
500
523
|
|
|
501
524
|
"""
|
|
502
525
|
-----------------------------------
|
|
@@ -521,7 +544,7 @@ class ExprComp(VtlVisitor):
|
|
|
521
544
|
token = c.getSymbol()
|
|
522
545
|
op_node = token.text
|
|
523
546
|
operand_node = self.visitExprComponent(ctx_list[2])
|
|
524
|
-
return UnaryOp(op_node, operand_node)
|
|
547
|
+
return UnaryOp(op=op_node, operand=operand_node, **extract_token_info(ctx))
|
|
525
548
|
|
|
526
549
|
def visitUnaryWithOptionalNumericComponent(
|
|
527
550
|
self, ctx: Parser.UnaryWithOptionalNumericComponentContext
|
|
@@ -546,7 +569,9 @@ class ExprComp(VtlVisitor):
|
|
|
546
569
|
for param in params:
|
|
547
570
|
params_nodes.append(self.visitOptionalExprComponent(param))
|
|
548
571
|
|
|
549
|
-
return ParamOp(
|
|
572
|
+
return ParamOp(
|
|
573
|
+
op=op_node, children=children_nodes, params=params_nodes, **extract_token_info(ctx)
|
|
574
|
+
)
|
|
550
575
|
|
|
551
576
|
def visitBinaryNumericComponent(self, ctx: Parser.BinaryNumericComponentContext):
|
|
552
577
|
ctx_list = list(ctx.getChildren())
|
|
@@ -557,7 +582,7 @@ class ExprComp(VtlVisitor):
|
|
|
557
582
|
left_node = self.visitExprComponent(ctx_list[2])
|
|
558
583
|
op_node = token.text
|
|
559
584
|
right_node = self.visitExprComponent(ctx_list[4])
|
|
560
|
-
return BinOp(left_node, op_node, right_node)
|
|
585
|
+
return BinOp(left=left_node, op=op_node, right=right_node, **extract_token_info(ctx))
|
|
561
586
|
|
|
562
587
|
"""
|
|
563
588
|
-----------------------------------
|
|
@@ -582,16 +607,19 @@ class ExprComp(VtlVisitor):
|
|
|
582
607
|
return self.visitDateDiffAtomComponent(ctx)
|
|
583
608
|
elif isinstance(ctx, Parser.DateAddAtomComponentContext):
|
|
584
609
|
return self.visitDateAddAtomComponentContext(ctx)
|
|
585
|
-
elif
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
610
|
+
elif isinstance(
|
|
611
|
+
ctx,
|
|
612
|
+
(
|
|
613
|
+
Parser.YearAtomComponentContext,
|
|
614
|
+
Parser.MonthAtomComponentContext,
|
|
615
|
+
Parser.DayOfMonthAtomComponentContext,
|
|
616
|
+
Parser.DayOfYearAtomComponentContext,
|
|
617
|
+
Parser.DayToYearAtomComponentContext,
|
|
618
|
+
Parser.DayToMonthAtomComponentContext,
|
|
619
|
+
Parser.YearToDayAtomComponentContext,
|
|
620
|
+
Parser.MonthToDayAtomComponentContext,
|
|
621
|
+
),
|
|
622
|
+
):
|
|
595
623
|
return self.visitTimeUnaryAtomComponent(ctx)
|
|
596
624
|
else:
|
|
597
625
|
raise NotImplementedError
|
|
@@ -614,7 +642,7 @@ class ExprComp(VtlVisitor):
|
|
|
614
642
|
# AST_ASTCONSTRUCTOR.15
|
|
615
643
|
raise NotImplementedError
|
|
616
644
|
|
|
617
|
-
return UnaryOp(op=op, operand=operand_node[0])
|
|
645
|
+
return UnaryOp(op=op, operand=operand_node[0], **extract_token_info(ctx))
|
|
618
646
|
|
|
619
647
|
def visitTimeShiftAtomComponent(self, ctx: Parser.TimeShiftAtomComponentContext):
|
|
620
648
|
"""
|
|
@@ -625,9 +653,13 @@ class ExprComp(VtlVisitor):
|
|
|
625
653
|
|
|
626
654
|
op = c.getSymbol().text
|
|
627
655
|
left_node = self.visitExprComponent(ctx_list[2])
|
|
628
|
-
right_node = Constant(
|
|
656
|
+
right_node = Constant(
|
|
657
|
+
type_="INTEGER_CONSTANT",
|
|
658
|
+
value=int(ctx_list[4].getSymbol().text),
|
|
659
|
+
**extract_token_info(ctx),
|
|
660
|
+
)
|
|
629
661
|
|
|
630
|
-
return BinOp(left=left_node, op=op, right=right_node)
|
|
662
|
+
return BinOp(left=left_node, op=op, right=right_node, **extract_token_info(ctx))
|
|
631
663
|
|
|
632
664
|
def visitFillTimeAtomComponent(self, ctx: Parser.FillTimeAtomComponentContext):
|
|
633
665
|
"""
|
|
@@ -640,17 +672,25 @@ class ExprComp(VtlVisitor):
|
|
|
640
672
|
children_node = [self.visitExprComponent(ctx_list[2])]
|
|
641
673
|
|
|
642
674
|
if len(ctx_list) > 4:
|
|
643
|
-
param_constant_node = [
|
|
675
|
+
param_constant_node = [
|
|
676
|
+
ParamConstant(
|
|
677
|
+
type_="PARAM_TIMESERIES",
|
|
678
|
+
value=ctx_list[4].getSymbol().text,
|
|
679
|
+
**extract_token_info(ctx),
|
|
680
|
+
)
|
|
681
|
+
]
|
|
644
682
|
else:
|
|
645
683
|
param_constant_node = []
|
|
646
684
|
|
|
647
|
-
return ParamOp(
|
|
685
|
+
return ParamOp(
|
|
686
|
+
op=op, children=children_node, params=param_constant_node, **extract_token_info(ctx)
|
|
687
|
+
)
|
|
648
688
|
|
|
649
689
|
def visitTimeAggAtomComponent(self, ctx: Parser.TimeAggAtomComponentContext):
|
|
650
690
|
"""
|
|
651
691
|
TIME_AGG LPAREN periodIndTo=STRING_CONSTANT (COMMA periodIndFrom=(STRING_CONSTANT| OPTIONAL ))?
|
|
652
692
|
(COMMA op=optionalExprComponent)? (COMMA (FIRST|LAST))? RPAREN # timeAggAtomComponent;
|
|
653
|
-
"""
|
|
693
|
+
""" # noqa E501
|
|
654
694
|
ctx_list = list(ctx.getChildren())
|
|
655
695
|
c = ctx_list[0]
|
|
656
696
|
|
|
@@ -676,20 +716,24 @@ class ExprComp(VtlVisitor):
|
|
|
676
716
|
if isinstance(operand_node, ID):
|
|
677
717
|
operand_node = None
|
|
678
718
|
elif isinstance(operand_node, Identifier):
|
|
679
|
-
operand_node = VarID(
|
|
719
|
+
operand_node = VarID(
|
|
720
|
+
value=operand_node.value, **extract_token_info(ctx.op)
|
|
721
|
+
) # Converting Identifier to VarID
|
|
680
722
|
else:
|
|
681
723
|
operand_node = None
|
|
682
724
|
|
|
683
|
-
if operand_node is None:
|
|
684
|
-
# AST_ASTCONSTRUCTOR.17
|
|
685
|
-
raise SemanticError("1-4-2-2")
|
|
686
725
|
return TimeAggregation(
|
|
687
|
-
op=op,
|
|
726
|
+
op=op,
|
|
727
|
+
operand=operand_node,
|
|
728
|
+
period_to=period_to,
|
|
729
|
+
period_from=period_from,
|
|
730
|
+
conf=conf,
|
|
731
|
+
**extract_token_info(ctx),
|
|
688
732
|
)
|
|
689
733
|
|
|
690
734
|
def visitCurrentDateAtomComponent(self, ctx: Parser.CurrentDateAtomComponentContext):
|
|
691
735
|
c = list(ctx.getChildren())[0]
|
|
692
|
-
return MulOp(op=c.getSymbol().text, children=[])
|
|
736
|
+
return MulOp(op=c.getSymbol().text, children=[], **extract_token_info(ctx))
|
|
693
737
|
|
|
694
738
|
def visitDateDiffAtomComponent(self, ctx: Parser.TimeShiftAtomComponentContext):
|
|
695
739
|
""" """
|
|
@@ -700,7 +744,7 @@ class ExprComp(VtlVisitor):
|
|
|
700
744
|
left_node = self.visitExprComponent(ctx_list[2])
|
|
701
745
|
right_node = self.visitExprComponent(ctx_list[4])
|
|
702
746
|
|
|
703
|
-
return BinOp(left=left_node, op=op, right=right_node)
|
|
747
|
+
return BinOp(left=left_node, op=op, right=right_node, **extract_token_info(ctx))
|
|
704
748
|
|
|
705
749
|
def visitDateAddAtomComponentContext(self, ctx: Parser.DateAddAtomComponentContext):
|
|
706
750
|
""" """
|
|
@@ -717,7 +761,9 @@ class ExprComp(VtlVisitor):
|
|
|
717
761
|
if len(ctx_list) > 6:
|
|
718
762
|
param_constant_node.append(self.visitExprComponent(ctx_list[6]))
|
|
719
763
|
|
|
720
|
-
return ParamOp(
|
|
764
|
+
return ParamOp(
|
|
765
|
+
op=op, children=children_node, params=param_constant_node, **extract_token_info(ctx)
|
|
766
|
+
)
|
|
721
767
|
|
|
722
768
|
"""
|
|
723
769
|
-----------------------------------
|
|
@@ -742,7 +788,7 @@ class ExprComp(VtlVisitor):
|
|
|
742
788
|
left_node = self.visitExprComponent(ctx_list[2])
|
|
743
789
|
op_node = token.text
|
|
744
790
|
right_node = self.visitExprComponent(ctx_list[4])
|
|
745
|
-
return BinOp(left_node, op_node, right_node)
|
|
791
|
+
return BinOp(left=left_node, op=op_node, right=right_node, **extract_token_info(ctx))
|
|
746
792
|
|
|
747
793
|
"""
|
|
748
794
|
-----------------------------------
|
|
@@ -773,7 +819,7 @@ class ExprComp(VtlVisitor):
|
|
|
773
819
|
for children in childrens:
|
|
774
820
|
children_nodes.append(self.visitExprComponent(children))
|
|
775
821
|
|
|
776
|
-
return MulOp(op_node, children_nodes)
|
|
822
|
+
return MulOp(op=op_node, children=children_nodes, **extract_token_info(ctx))
|
|
777
823
|
|
|
778
824
|
def visitCharsetMatchAtomComponent(self, ctx: Parser.CharsetMatchAtomComponentContext):
|
|
779
825
|
ctx_list = list(ctx.getChildren())
|
|
@@ -783,7 +829,7 @@ class ExprComp(VtlVisitor):
|
|
|
783
829
|
left_node = self.visitExprComponent(ctx_list[2])
|
|
784
830
|
op_node = token.text
|
|
785
831
|
right_node = self.visitExprComponent(ctx_list[4])
|
|
786
|
-
return BinOp(left_node, op_node, right_node)
|
|
832
|
+
return BinOp(left=left_node, op=op_node, right=right_node, **extract_token_info(ctx))
|
|
787
833
|
|
|
788
834
|
def visitIsNullAtomComponent(self, ctx: Parser.IsNullAtomComponentContext):
|
|
789
835
|
ctx_list = list(ctx.getChildren())
|
|
@@ -791,7 +837,7 @@ class ExprComp(VtlVisitor):
|
|
|
791
837
|
token = c.getSymbol()
|
|
792
838
|
op_node = token.text
|
|
793
839
|
operand_node = self.visitExprComponent(ctx_list[2])
|
|
794
|
-
return UnaryOp(op_node, operand_node)
|
|
840
|
+
return UnaryOp(op=op_node, operand=operand_node, **extract_token_info(ctx))
|
|
795
841
|
|
|
796
842
|
"""
|
|
797
843
|
-----------------------------------
|
|
@@ -811,12 +857,12 @@ class ExprComp(VtlVisitor):
|
|
|
811
857
|
ctx_list = list(ctx.getChildren())
|
|
812
858
|
op_node = ctx_list[0].getSymbol().text
|
|
813
859
|
operand_node = self.visitExprComponent(ctx_list[2])
|
|
814
|
-
return Aggregation(op_node, operand_node)
|
|
860
|
+
return Aggregation(op=op_node, operand=operand_node, **extract_token_info(ctx))
|
|
815
861
|
|
|
816
862
|
def visitCountAggrComp(self, ctx: Parser.CountAggrCompContext):
|
|
817
863
|
ctx_list = list(ctx.getChildren())
|
|
818
864
|
op_node = ctx_list[0].getSymbol().text
|
|
819
|
-
return Aggregation(op_node)
|
|
865
|
+
return Aggregation(op=op_node, **extract_token_info(ctx))
|
|
820
866
|
|
|
821
867
|
"""
|
|
822
868
|
-----------------------------------
|
|
@@ -825,7 +871,6 @@ class ExprComp(VtlVisitor):
|
|
|
825
871
|
"""
|
|
826
872
|
|
|
827
873
|
def visitAnalyticFunctionsComponents(self, ctx: Parser.AnalyticFunctionsComponentsContext):
|
|
828
|
-
|
|
829
874
|
if isinstance(ctx, Parser.AnSimpleFunctionComponentContext):
|
|
830
875
|
return self.visitAnSimpleFunctionComponent(ctx)
|
|
831
876
|
elif isinstance(ctx, Parser.LagOrLeadAnComponentContext):
|
|
@@ -861,7 +906,12 @@ class ExprComp(VtlVisitor):
|
|
|
861
906
|
raise NotImplementedError
|
|
862
907
|
|
|
863
908
|
return Analytic(
|
|
864
|
-
op=op_node,
|
|
909
|
+
op=op_node,
|
|
910
|
+
operand=operand,
|
|
911
|
+
partition_by=partition_by,
|
|
912
|
+
order_by=order_by,
|
|
913
|
+
window=params,
|
|
914
|
+
**extract_token_info(ctx),
|
|
865
915
|
)
|
|
866
916
|
|
|
867
917
|
def visitLagOrLeadAnComponent(self, ctx: Parser.LagOrLeadAnComponentContext):
|
|
@@ -891,7 +941,12 @@ class ExprComp(VtlVisitor):
|
|
|
891
941
|
continue
|
|
892
942
|
|
|
893
943
|
return Analytic(
|
|
894
|
-
op=op_node,
|
|
944
|
+
op=op_node,
|
|
945
|
+
operand=operand,
|
|
946
|
+
partition_by=partition_by,
|
|
947
|
+
order_by=order_by,
|
|
948
|
+
params=params,
|
|
949
|
+
**extract_token_info(ctx),
|
|
895
950
|
)
|
|
896
951
|
|
|
897
952
|
def visitRankAnComponent(self, ctx: Parser.RankAnComponentContext):
|
|
@@ -911,7 +966,12 @@ class ExprComp(VtlVisitor):
|
|
|
911
966
|
continue
|
|
912
967
|
|
|
913
968
|
return Analytic(
|
|
914
|
-
op=op_node,
|
|
969
|
+
op=op_node,
|
|
970
|
+
operand=None,
|
|
971
|
+
partition_by=partition_by,
|
|
972
|
+
order_by=order_by,
|
|
973
|
+
window=None,
|
|
974
|
+
**extract_token_info(ctx),
|
|
915
975
|
)
|
|
916
976
|
|
|
917
977
|
def visitRatioToReportAnComponent(self, ctx: Parser.RatioToReportAnComponentContext):
|
|
@@ -926,5 +986,10 @@ class ExprComp(VtlVisitor):
|
|
|
926
986
|
partition_by = Terminals().visitPartitionByClause(ctx_list[5])
|
|
927
987
|
|
|
928
988
|
return Analytic(
|
|
929
|
-
op=op_node,
|
|
989
|
+
op=op_node,
|
|
990
|
+
operand=operand,
|
|
991
|
+
partition_by=partition_by,
|
|
992
|
+
order_by=order_by,
|
|
993
|
+
window=params,
|
|
994
|
+
**extract_token_info(ctx),
|
|
930
995
|
)
|