vtlengine 1.0.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
vtlengine/AST/DAG/__init__.py
CHANGED
|
@@ -6,16 +6,31 @@ Description
|
|
|
6
6
|
-----------
|
|
7
7
|
Direct Acyclic Graph.
|
|
8
8
|
"""
|
|
9
|
+
|
|
9
10
|
import copy
|
|
10
11
|
from dataclasses import dataclass
|
|
11
12
|
from typing import Any, Dict, Optional
|
|
12
13
|
|
|
13
14
|
import networkx as nx
|
|
14
15
|
|
|
15
|
-
from vtlengine.AST import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
from vtlengine.AST import (
|
|
17
|
+
AST,
|
|
18
|
+
BinOp,
|
|
19
|
+
VarID,
|
|
20
|
+
Aggregation,
|
|
21
|
+
Analytic,
|
|
22
|
+
JoinOp,
|
|
23
|
+
ParamOp,
|
|
24
|
+
Operator,
|
|
25
|
+
Identifier,
|
|
26
|
+
DefIdentifier,
|
|
27
|
+
Start,
|
|
28
|
+
HRuleset,
|
|
29
|
+
RegularAggregation,
|
|
30
|
+
PersistentAssignment,
|
|
31
|
+
Assignment,
|
|
32
|
+
DPRuleset,
|
|
33
|
+
)
|
|
19
34
|
from vtlengine.AST.ASTTemplate import ASTTemplate
|
|
20
35
|
from vtlengine.AST.DAG._words import INSERT, DELETE, OUTPUTS, PERSISTENT, INPUTS, GLOBAL
|
|
21
36
|
from vtlengine.AST.Grammar.tokens import AS, MEMBERSHIP, TO
|
|
@@ -116,9 +131,7 @@ class DAGAnalyzer(ASTTemplate):
|
|
|
116
131
|
|
|
117
132
|
@classmethod
|
|
118
133
|
def createDAG(cls, ast: AST):
|
|
119
|
-
"""
|
|
120
|
-
|
|
121
|
-
"""
|
|
134
|
+
""" """
|
|
122
135
|
# Visit AST.
|
|
123
136
|
dag = cls()
|
|
124
137
|
dag.visit(ast)
|
|
@@ -142,17 +155,16 @@ class DAGAnalyzer(ASTTemplate):
|
|
|
142
155
|
error_keys[aux_v1] = dag.dependencies[aux_v1]
|
|
143
156
|
break
|
|
144
157
|
raise Exception(
|
|
145
|
-
|
|
146
|
-
|
|
158
|
+
"Vtl Script contains Cycles, no DAG established.\nSuggestion {}, "
|
|
159
|
+
"more_info:{}".format(error, error_keys)
|
|
160
|
+
) from None
|
|
147
161
|
except SemanticError as error:
|
|
148
162
|
raise error
|
|
149
163
|
except Exception as error:
|
|
150
|
-
raise Exception(
|
|
164
|
+
raise Exception("Error creating DAG.") from error
|
|
151
165
|
|
|
152
166
|
def loadVertex(self):
|
|
153
|
-
"""
|
|
154
|
-
|
|
155
|
-
"""
|
|
167
|
+
""" """
|
|
156
168
|
# For each vertex
|
|
157
169
|
for key, statement in self.dependencies.items():
|
|
158
170
|
output = statement[OUTPUTS] + statement[PERSISTENT]
|
|
@@ -164,9 +176,7 @@ class DAGAnalyzer(ASTTemplate):
|
|
|
164
176
|
self.nov = len(self.vertex)
|
|
165
177
|
|
|
166
178
|
def loadEdges(self):
|
|
167
|
-
"""
|
|
168
|
-
|
|
169
|
-
"""
|
|
179
|
+
""" """
|
|
170
180
|
if len(self.vertex) != 0:
|
|
171
181
|
countEdges = 0
|
|
172
182
|
# For each vertex
|
|
@@ -182,9 +192,7 @@ class DAGAnalyzer(ASTTemplate):
|
|
|
182
192
|
countEdges += 1
|
|
183
193
|
|
|
184
194
|
def nx_topologicalSort(self):
|
|
185
|
-
"""
|
|
186
|
-
|
|
187
|
-
"""
|
|
195
|
+
""" """
|
|
188
196
|
edges = list(self.edges.values())
|
|
189
197
|
DAG = nx.DiGraph()
|
|
190
198
|
DAG.add_nodes_from(self.vertex)
|
|
@@ -208,26 +216,23 @@ class DAGAnalyzer(ASTTemplate):
|
|
|
208
216
|
non_repeated_outputs.append(statement.left.value)
|
|
209
217
|
|
|
210
218
|
def sortAST(self, ast: AST):
|
|
211
|
-
"""
|
|
212
|
-
|
|
213
|
-
"""
|
|
219
|
+
""" """
|
|
214
220
|
statements_nodes = ast.children
|
|
215
|
-
HRuleStatements: list = [HRule for HRule in statements_nodes if
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
221
|
+
HRuleStatements: list = [HRule for HRule in statements_nodes if isinstance(HRule, HRuleset)]
|
|
222
|
+
DPRuleStatement: list = [
|
|
223
|
+
DPRule for DPRule in statements_nodes if isinstance(DPRule, DPRuleset)
|
|
224
|
+
]
|
|
219
225
|
DOStatement: list = [DO for DO in statements_nodes if isinstance(DO, Operator)]
|
|
220
|
-
MLStatements: list = [
|
|
221
|
-
|
|
226
|
+
MLStatements: list = [
|
|
227
|
+
ML for ML in statements_nodes if not isinstance(ML, (HRuleset, DPRuleset, Operator))
|
|
228
|
+
]
|
|
222
229
|
|
|
223
230
|
intermediate = self.sort_elements(MLStatements)
|
|
224
231
|
self.check_overwriting(intermediate)
|
|
225
232
|
ast.children = HRuleStatements + DPRuleStatement + DOStatement + intermediate
|
|
226
233
|
|
|
227
234
|
def statementStructure(self) -> dict:
|
|
228
|
-
"""
|
|
229
|
-
|
|
230
|
-
"""
|
|
235
|
+
""" """
|
|
231
236
|
inputs = list(set(self.inputs))
|
|
232
237
|
outputs = list(set(self.outputs))
|
|
233
238
|
persistent = list(set(self.persistent))
|
|
@@ -267,9 +272,11 @@ class DAGAnalyzer(ASTTemplate):
|
|
|
267
272
|
|
|
268
273
|
# Analyze inputs and outputs per each statement.
|
|
269
274
|
self.dependencies[self.numberOfStatements] = copy.deepcopy(
|
|
270
|
-
self.statementStructure()
|
|
275
|
+
self.statementStructure()
|
|
276
|
+
)
|
|
271
277
|
|
|
272
|
-
# Count the number of statements in order to name the scope symbol table for
|
|
278
|
+
# Count the number of statements in order to name the scope symbol table for
|
|
279
|
+
# each one.
|
|
273
280
|
self.numberOfStatements += 1
|
|
274
281
|
|
|
275
282
|
self.alias = []
|
|
@@ -376,8 +383,9 @@ class HRDAGAnalyzer(DAGAnalyzer):
|
|
|
376
383
|
error_keys[aux_v1] = dag.dependencies[aux_v1]
|
|
377
384
|
break
|
|
378
385
|
raise Exception(
|
|
379
|
-
f
|
|
380
|
-
f
|
|
386
|
+
f"Vtl Script contains Cycles, no DAG established."
|
|
387
|
+
f"\nSuggestion {error}, more_info:{error_keys}"
|
|
388
|
+
)
|
|
381
389
|
|
|
382
390
|
def visit_HRuleset(self, node: HRuleset) -> None:
|
|
383
391
|
"""
|
vtlengine/AST/DAG/_words.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# DS analysis
|
|
2
|
-
INSERT =
|
|
3
|
-
DELETE =
|
|
4
|
-
GLOBAL =
|
|
2
|
+
INSERT = "insertion"
|
|
3
|
+
DELETE = "deletion"
|
|
4
|
+
GLOBAL = "global_inputs"
|
|
5
5
|
|
|
6
6
|
INPUTS = "inputs"
|
|
7
7
|
OUTPUTS = "outputs"
|
|
8
8
|
PERSISTENT = "persistent"
|
|
9
|
-
STATEMENT_ =
|
|
9
|
+
STATEMENT_ = "statement"
|