vtlengine 1.1rc2__py3-none-any.whl → 1.2.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.

Potentially problematic release.


This version of vtlengine might be problematic. Click here for more details.

Files changed (44) hide show
  1. vtlengine/API/_InternalApi.py +288 -29
  2. vtlengine/API/__init__.py +277 -70
  3. vtlengine/AST/ASTComment.py +56 -0
  4. vtlengine/AST/ASTConstructor.py +71 -18
  5. vtlengine/AST/ASTConstructorModules/Expr.py +197 -75
  6. vtlengine/AST/ASTConstructorModules/ExprComponents.py +81 -38
  7. vtlengine/AST/ASTConstructorModules/Terminals.py +76 -31
  8. vtlengine/AST/ASTConstructorModules/__init__.py +50 -0
  9. vtlengine/AST/ASTEncoders.py +4 -0
  10. vtlengine/AST/ASTString.py +622 -0
  11. vtlengine/AST/ASTTemplate.py +28 -2
  12. vtlengine/AST/DAG/__init__.py +44 -6
  13. vtlengine/AST/DAG/_words.py +1 -0
  14. vtlengine/AST/Grammar/Vtl.g4 +7 -7
  15. vtlengine/AST/Grammar/lexer.py +19759 -1112
  16. vtlengine/AST/Grammar/parser.py +17996 -3199
  17. vtlengine/AST/__init__.py +127 -14
  18. vtlengine/Exceptions/messages.py +14 -2
  19. vtlengine/Interpreter/__init__.py +90 -11
  20. vtlengine/Model/__init__.py +9 -4
  21. vtlengine/Operators/Aggregation.py +13 -6
  22. vtlengine/Operators/Analytic.py +19 -13
  23. vtlengine/Operators/CastOperator.py +5 -2
  24. vtlengine/Operators/Clause.py +26 -18
  25. vtlengine/Operators/Comparison.py +3 -1
  26. vtlengine/Operators/Conditional.py +40 -18
  27. vtlengine/Operators/General.py +3 -1
  28. vtlengine/Operators/HROperators.py +3 -1
  29. vtlengine/Operators/Join.py +4 -2
  30. vtlengine/Operators/Time.py +22 -15
  31. vtlengine/Operators/Validation.py +5 -2
  32. vtlengine/Operators/__init__.py +15 -8
  33. vtlengine/Utils/__Virtual_Assets.py +34 -0
  34. vtlengine/Utils/__init__.py +49 -0
  35. vtlengine/__init__.py +4 -2
  36. vtlengine/files/parser/__init__.py +16 -26
  37. vtlengine/files/parser/_rfc_dialect.py +1 -1
  38. vtlengine/py.typed +0 -0
  39. vtlengine-1.2.0.dist-info/METADATA +92 -0
  40. vtlengine-1.2.0.dist-info/RECORD +63 -0
  41. {vtlengine-1.1rc2.dist-info → vtlengine-1.2.0.dist-info}/WHEEL +1 -1
  42. vtlengine-1.1rc2.dist-info/METADATA +0 -248
  43. vtlengine-1.1rc2.dist-info/RECORD +0 -59
  44. {vtlengine-1.1rc2.dist-info → vtlengine-1.2.0.dist-info}/LICENSE.md +0 -0
vtlengine/AST/__init__.py CHANGED
@@ -11,7 +11,7 @@ from dataclasses import dataclass
11
11
  from typing import Any, Dict, List, Optional, Type, Union
12
12
 
13
13
  from vtlengine.DataTypes import ScalarType
14
- from vtlengine.Model import Role
14
+ from vtlengine.Model import Dataset, Role
15
15
 
16
16
 
17
17
  @dataclass
@@ -20,6 +20,11 @@ class AST:
20
20
  AST: (children)
21
21
  """
22
22
 
23
+ line_start: int
24
+ column_start: int
25
+ line_stop: int
26
+ column_stop: int
27
+
23
28
  @classmethod
24
29
  def __all_annotations(cls) -> Dict[str, Any]:
25
30
  class_attributes = {}
@@ -47,6 +52,30 @@ class AST:
47
52
 
48
53
  __repr__ = __str__
49
54
 
55
+ def ast_equality(self, other):
56
+ if not isinstance(other, self.__class__):
57
+ return False
58
+ for k in self.__all_annotations():
59
+ if (
60
+ getattr(self, k) != getattr(other, k)
61
+ and k not in AST.__annotations__
62
+ and k != "children" # We do not want to compare the children order here
63
+ ):
64
+ return False
65
+ return True
66
+
67
+ __eq__ = ast_equality
68
+
69
+
70
+ @dataclass
71
+ class Comment(AST):
72
+ """
73
+ Comment: (value)
74
+ """
75
+
76
+ value: str
77
+ __eq__ = AST.ast_equality
78
+
50
79
 
51
80
  @dataclass
52
81
  class Start(AST):
@@ -56,6 +85,8 @@ class Start(AST):
56
85
 
57
86
  children: List[AST]
58
87
 
88
+ __eq__ = AST.ast_equality
89
+
59
90
 
60
91
  @dataclass
61
92
  class Assignment(AST):
@@ -67,6 +98,8 @@ class Assignment(AST):
67
98
  op: str
68
99
  right: AST
69
100
 
101
+ __eq__ = AST.ast_equality
102
+
70
103
 
71
104
  @dataclass
72
105
  class PersistentAssignment(Assignment):
@@ -85,7 +118,9 @@ class VarID(AST):
85
118
  Could be: DATASET or a COMPONENT.
86
119
  """
87
120
 
88
- value: Any
121
+ value: str
122
+
123
+ __eq__ = AST.ast_equality
89
124
 
90
125
 
91
126
  @dataclass
@@ -100,6 +135,8 @@ class UnaryOp(AST):
100
135
  op: str
101
136
  operand: AST
102
137
 
138
+ __eq__ = AST.ast_equality
139
+
103
140
 
104
141
  @dataclass
105
142
  class BinOp(AST):
@@ -113,6 +150,8 @@ class BinOp(AST):
113
150
  op: str
114
151
  right: AST
115
152
 
153
+ __eq__ = AST.ast_equality
154
+
116
155
 
117
156
  @dataclass
118
157
  class MulOp(AST):
@@ -124,6 +163,8 @@ class MulOp(AST):
124
163
  op: str
125
164
  children: List[AST]
126
165
 
166
+ __eq__ = AST.ast_equality
167
+
127
168
 
128
169
  @dataclass
129
170
  class ParamOp(AST):
@@ -137,12 +178,16 @@ class ParamOp(AST):
137
178
  children: List[AST]
138
179
  params: List[AST]
139
180
 
181
+ __eq__ = AST.ast_equality
182
+
140
183
 
141
184
  @dataclass
142
185
  class UDOCall(AST):
143
186
  op: str
144
187
  params: List[AST]
145
188
 
189
+ __eq__ = AST.ast_equality
190
+
146
191
 
147
192
  @dataclass
148
193
  class JoinOp(AST):
@@ -156,9 +201,11 @@ class JoinOp(AST):
156
201
 
157
202
  op: str
158
203
  clauses: List[AST]
159
- using: Optional[List[AST]]
204
+ using: Optional[List[str]]
160
205
  isLast: bool = False
161
206
 
207
+ __eq__ = AST.ast_equality
208
+
162
209
 
163
210
  @dataclass
164
211
  class Constant(AST):
@@ -172,6 +219,8 @@ class Constant(AST):
172
219
  type_: str
173
220
  value: Optional[Union[str, int, float, bool]]
174
221
 
222
+ __eq__ = AST.ast_equality
223
+
175
224
 
176
225
  @dataclass
177
226
  class ParamConstant(Constant):
@@ -184,6 +233,8 @@ class ParamConstant(Constant):
184
233
  type_: str
185
234
  value: str
186
235
 
236
+ __eq__ = AST.ast_equality
237
+
187
238
 
188
239
  @dataclass
189
240
  class Identifier(AST):
@@ -194,6 +245,8 @@ class Identifier(AST):
194
245
  value: str
195
246
  kind: str
196
247
 
248
+ __eq__ = AST.ast_equality
249
+
197
250
 
198
251
  @dataclass
199
252
  class ID(AST):
@@ -206,6 +259,8 @@ class ID(AST):
206
259
  type_: str
207
260
  value: str
208
261
 
262
+ __eq__ = AST.ast_equality
263
+
209
264
 
210
265
  @dataclass
211
266
  class Collection(AST):
@@ -220,6 +275,8 @@ class Collection(AST):
220
275
  children: List[AST]
221
276
  kind: str = "Set"
222
277
 
278
+ __eq__ = AST.ast_equality
279
+
223
280
 
224
281
  @dataclass
225
282
  class Windowing(AST):
@@ -234,11 +291,13 @@ class Windowing(AST):
234
291
  """
235
292
 
236
293
  type_: str
237
- start: str
294
+ start: Union[int, str]
238
295
  start_mode: str
239
296
  stop: Union[int, str]
240
297
  stop_mode: str
241
298
 
299
+ __eq__ = AST.ast_equality
300
+
242
301
 
243
302
  @dataclass
244
303
  class OrderBy(AST):
@@ -249,6 +308,8 @@ class OrderBy(AST):
249
308
  if self.order not in ["asc", "desc"]:
250
309
  raise ValueError(f"Invalid order: {self.order}")
251
310
 
311
+ __eq__ = AST.ast_equality
312
+
252
313
 
253
314
  @dataclass
254
315
  class Analytic(AST):
@@ -274,6 +335,8 @@ class Analytic(AST):
274
335
  if self.partition_by is None and self.order_by is None:
275
336
  raise ValueError("Partition by or order by must be provided on Analytic.")
276
337
 
338
+ __eq__ = AST.ast_equality
339
+
277
340
 
278
341
  @dataclass
279
342
  class RegularAggregation(AST):
@@ -288,6 +351,8 @@ class RegularAggregation(AST):
288
351
  dataset: Optional[AST] = None
289
352
  isLast: bool = False
290
353
 
354
+ __eq__ = AST.ast_equality
355
+
291
356
 
292
357
  @dataclass
293
358
  class RenameNode(AST):
@@ -298,6 +363,8 @@ class RenameNode(AST):
298
363
  old_name: str
299
364
  new_name: str
300
365
 
366
+ __eq__ = AST.ast_equality
367
+
301
368
 
302
369
  @dataclass
303
370
  class Aggregation(AST):
@@ -316,6 +383,8 @@ class Aggregation(AST):
316
383
  grouping: Optional[List[AST]] = None
317
384
  having_clause: Optional[AST] = None
318
385
 
386
+ __eq__ = AST.ast_equality
387
+
319
388
 
320
389
  @dataclass
321
390
  class TimeAggregation(AST):
@@ -331,6 +400,8 @@ class TimeAggregation(AST):
331
400
  operand: Optional[AST] = None
332
401
  conf: Optional[str] = None
333
402
 
403
+ __eq__ = AST.ast_equality
404
+
334
405
 
335
406
  @dataclass
336
407
  class If(AST):
@@ -342,15 +413,14 @@ class If(AST):
342
413
  thenOp: AST
343
414
  elseOp: AST
344
415
 
416
+ __eq__ = AST.ast_equality
417
+
345
418
 
346
- class CaseObj:
419
+ @dataclass
420
+ class CaseObj(AST):
347
421
  condition: AST
348
422
  thenOp: AST
349
423
 
350
- def __init__(self, condition: AST, thenOp: AST):
351
- self.condition = condition
352
- self.thenOp = thenOp
353
-
354
424
 
355
425
  @dataclass
356
426
  class Case(AST):
@@ -361,6 +431,8 @@ class Case(AST):
361
431
  cases: List[CaseObj]
362
432
  elseOp: AST
363
433
 
434
+ __eq__ = AST.ast_equality
435
+
364
436
 
365
437
  @dataclass
366
438
  class Validation(AST):
@@ -375,6 +447,8 @@ class Validation(AST):
375
447
  imbalance: Optional[AST]
376
448
  invalid: bool
377
449
 
450
+ __eq__ = AST.ast_equality
451
+
378
452
 
379
453
  @dataclass
380
454
  class ComponentType(AST):
@@ -386,6 +460,8 @@ class ComponentType(AST):
386
460
  data_type: Optional[Type[ScalarType]] = None
387
461
  role: Optional[Role] = None
388
462
 
463
+ __eq__ = AST.ast_equality
464
+
389
465
 
390
466
  @dataclass
391
467
  class ASTScalarType(AST):
@@ -400,6 +476,8 @@ class DatasetType(AST):
400
476
 
401
477
  components: List[ComponentType]
402
478
 
479
+ __eq__ = AST.ast_equality
480
+
403
481
 
404
482
  @dataclass
405
483
  class Types(AST):
@@ -418,6 +496,8 @@ class Types(AST):
418
496
  nullable: Optional[bool]
419
497
  name: Optional[str] = None
420
498
 
499
+ __eq__ = AST.ast_equality
500
+
421
501
 
422
502
  @dataclass
423
503
  class Argument(AST):
@@ -429,6 +509,8 @@ class Argument(AST):
429
509
  type_: Type[ScalarType]
430
510
  default: Optional[AST]
431
511
 
512
+ __eq__ = AST.ast_equality
513
+
432
514
 
433
515
  @dataclass
434
516
  class Operator(AST):
@@ -441,6 +523,8 @@ class Operator(AST):
441
523
  output_type: str
442
524
  expression: AST
443
525
 
526
+ __eq__ = AST.ast_equality
527
+
444
528
 
445
529
  # TODO: Is this class necessary?
446
530
  @dataclass
@@ -452,6 +536,8 @@ class DefIdentifier(AST):
452
536
  value: str
453
537
  kind: str
454
538
 
539
+ __eq__ = AST.ast_equality
540
+
455
541
 
456
542
  @dataclass
457
543
  class DPRIdentifier(AST):
@@ -463,6 +549,8 @@ class DPRIdentifier(AST):
463
549
  kind: str
464
550
  alias: Optional[str] = None
465
551
 
552
+ __eq__ = AST.ast_equality
553
+
466
554
 
467
555
  # TODO: Are HRBinOp and HRUnOp necessary?
468
556
  @dataclass
@@ -476,6 +564,8 @@ class HRBinOp(AST):
476
564
  op: str
477
565
  right: DefIdentifier
478
566
 
567
+ __eq__ = AST.ast_equality
568
+
479
569
 
480
570
  @dataclass
481
571
  class HRUnOp(AST):
@@ -487,6 +577,8 @@ class HRUnOp(AST):
487
577
  op: str
488
578
  operand: DefIdentifier
489
579
 
580
+ __eq__ = AST.ast_equality
581
+
490
582
 
491
583
  # TODO: Unify HRule and DPRule?
492
584
  @dataclass
@@ -497,8 +589,10 @@ class HRule(AST):
497
589
 
498
590
  name: Optional[str]
499
591
  rule: HRBinOp
500
- erCode: Optional[Constant]
501
- erLevel: Optional[Constant]
592
+ erCode: Optional[str]
593
+ erLevel: Optional[int]
594
+
595
+ __eq__ = AST.ast_equality
502
596
 
503
597
 
504
598
  @dataclass
@@ -509,8 +603,10 @@ class DPRule(AST):
509
603
 
510
604
  name: Optional[str]
511
605
  rule: HRBinOp
512
- erCode: Optional[Constant]
513
- erLevel: Optional[Constant]
606
+ erCode: Optional[str]
607
+ erLevel: Optional[int]
608
+
609
+ __eq__ = AST.ast_equality
514
610
 
515
611
 
516
612
  # TODO: Unify HRuleset and DPRuleset?
@@ -525,6 +621,8 @@ class HRuleset(AST):
525
621
  element: DefIdentifier
526
622
  rules: List[HRule]
527
623
 
624
+ __eq__ = AST.ast_equality
625
+
528
626
 
529
627
  @dataclass
530
628
  class DPRuleset(AST):
@@ -537,6 +635,8 @@ class DPRuleset(AST):
537
635
  params: Union[DefIdentifier, list]
538
636
  rules: List[DPRule]
539
637
 
638
+ __eq__ = AST.ast_equality
639
+
540
640
 
541
641
  @dataclass
542
642
  class EvalOp(AST):
@@ -548,9 +648,11 @@ class EvalOp(AST):
548
648
 
549
649
  name: str
550
650
  operands: List[AST]
551
- output: Optional[str]
651
+ output: Optional[Dataset]
552
652
  language: Optional[str]
553
653
 
654
+ __eq__ = AST.ast_equality
655
+
554
656
 
555
657
  @dataclass
556
658
  class NoOp(AST):
@@ -559,3 +661,14 @@ class NoOp(AST):
559
661
  """
560
662
 
561
663
  pass
664
+
665
+
666
+ @dataclass
667
+ class ParFunction(AST):
668
+ """
669
+ ParFunction: (operand)
670
+ """
671
+
672
+ operand: AST
673
+
674
+ __eq__ = AST.ast_equality
@@ -9,12 +9,22 @@ All exceptions exposed by the Vtl engine.
9
9
 
10
10
  centralised_messages = {
11
11
  # Input Validation errors
12
+ "0-1-1-1": "invalid script format type: {format_}. Input must be a string, "
13
+ "TransformationScheme or Path object",
12
14
  "0-1-2-1": "Invalid json structure because additional properties have been supplied "
13
15
  "on file {filename}.",
14
16
  "0-1-2-2": "Errors found on file {filename}: {errors}",
15
17
  "0-1-2-3": "Component {component} is duplicated.",
16
18
  "0-1-2-4": "Invalid json structure because {err} on file {filename}.",
17
19
  "0-1-2-5": "File {file} must be encoded in utf-8 (without BOM).",
20
+ # Run SDMX errors
21
+ "0-1-3-1": "Expected exactly one input dataset in the whole script, found: {number_datasets}",
22
+ "0-1-3-2": "SDMX Dataset {schema} requires to have a Schema object defined as structure",
23
+ "0-1-3-3": "If no mappings are provided, only one dataset is allowed.",
24
+ "0-1-3-4": "Dataset {short_urn} not found in mapping dictionary.",
25
+ "0-1-3-5": "Dataset {dataset_name} not found in the input datasets.",
26
+ "0-1-3-6": "Input name {missing} not found in the input datasets.",
27
+ "0-1-3-7": "Invalid input datasets type: {type_}. Expected a sequence of PandasDataset.",
18
28
  # JSON Schema validations
19
29
  "0-3-1-1": "Dataset {dataset} is not valid according to JSON schema",
20
30
  # Infer Data Structure errors
@@ -206,6 +216,8 @@ centralised_messages = {
206
216
  "1-1-19-9": "At op {op}: {op} can only be applied to a {comp_type} with a {param}",
207
217
  # New Unary time operators
208
218
  "1-1-19-10": "{op} can only be applied to operands with data type as Date or Time Period",
219
+ "1-1-19-11": "The time aggregation operand has to be "
220
+ "defined if not used inside an aggregation.",
209
221
  # Other time operators
210
222
  "2-1-19-1": "At op {op}: Invalid values {value_1} and {value_2} for duration, "
211
223
  "periodIndTo parameter must be a larger duration value than the "
@@ -232,8 +244,8 @@ centralised_messages = {
232
244
  "2-3-1": "{comp_type} {comp_name} not found.",
233
245
  "2-3-2": "{op_type} cannot be used with {node_op} operators.",
234
246
  "2-3-4": "{op} operator must have a {comp}",
235
- "2-3-5": "Expected {param_type}, got {type_name} on UDO {op}, parameter {param_name}",
236
- "2-3-6": "Dataset {dataset_name} not found, please check input datastructures",
247
+ "2-3-5": "Expected {param_type}, got {type_name} on UDO {op}, parameter {param_name}.",
248
+ "2-3-6": "Dataset or scalar {dataset_name} not found, please check input datastructures.",
237
249
  "2-3-9": "{comp_type} {comp_name} not found in {param}.",
238
250
  "2-3-10": "No {comp_type} have been defined.",
239
251
  "2-3-11": "{pos} operand must be a dataset.",