vtlengine 1.0.1__tar.gz → 1.0.3__tar.gz
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-1.0.1 → vtlengine-1.0.3}/PKG-INFO +17 -5
- {vtlengine-1.0.1 → vtlengine-1.0.3}/README.md +8 -1
- vtlengine-1.0.3/pyproject.toml +89 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/API/_InternalApi.py +19 -8
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/API/__init__.py +9 -9
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTConstructor.py +23 -43
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTConstructorModules/Expr.py +147 -71
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTConstructorModules/ExprComponents.py +104 -40
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTConstructorModules/Terminals.py +28 -39
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTTemplate.py +16 -1
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/DAG/__init__.py +12 -15
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/Grammar/Vtl.g4 +49 -20
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/Grammar/VtlTokens.g4 +13 -1
- vtlengine-1.0.3/src/vtlengine/AST/Grammar/lexer.py +2139 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/Grammar/parser.py +5758 -3939
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/Grammar/tokens.py +12 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/VtlVisitor.py +9 -2
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/__init__.py +21 -3
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/DataTypes/TimeHandling.py +12 -7
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/DataTypes/__init__.py +17 -24
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Exceptions/__init__.py +43 -1
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Exceptions/messages.py +82 -62
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Interpreter/__init__.py +125 -120
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Model/__init__.py +17 -12
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Aggregation.py +14 -14
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Analytic.py +56 -31
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Assignment.py +2 -3
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Boolean.py +5 -7
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/CastOperator.py +12 -13
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Clause.py +11 -13
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Comparison.py +31 -17
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Conditional.py +157 -17
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/General.py +4 -4
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/HROperators.py +41 -34
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Join.py +18 -22
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Numeric.py +76 -39
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/RoleSetter.py +6 -8
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Set.py +7 -12
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/String.py +19 -27
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Time.py +366 -43
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/Validation.py +4 -7
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Operators/__init__.py +38 -41
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/Utils/__init__.py +149 -94
- vtlengine-1.0.3/src/vtlengine/__init__.py +3 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/files/output/_time_period_representation.py +0 -1
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/files/parser/__init__.py +18 -18
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/files/parser/_time_checking.py +3 -2
- vtlengine-1.0.1/pyproject.toml +0 -66
- vtlengine-1.0.1/src/vtlengine/AST/Grammar/lexer.py +0 -2029
- vtlengine-1.0.1/src/vtlengine/__init__.py +0 -3
- {vtlengine-1.0.1 → vtlengine-1.0.3}/LICENSE.md +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTConstructorModules/__init__.py +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTDataExchange.py +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTEncoders.py +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/ASTVisitor.py +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/DAG/_words.py +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/AST/Grammar/__init__.py +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/DataTypes/NumericTypesHandling.py +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/files/__init__.py +0 -0
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/files/output/__init__.py +2 -2
- {vtlengine-1.0.1 → vtlengine-1.0.3}/src/vtlengine/files/parser/_rfc_dialect.py +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vtlengine
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Run and Validate VTL Scripts
|
|
5
5
|
License: AGPL-3.0
|
|
6
|
+
Keywords: vtl,sdmx,vtlengine,Validation and Transformation Language
|
|
6
7
|
Author: MeaningfulData
|
|
7
8
|
Author-email: info@meaningfuldata.eu
|
|
8
9
|
Requires-Python: >=3.10,<4.0
|
|
9
|
-
Classifier: Development Status ::
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
11
|
Classifier: Intended Audience :: Developers
|
|
11
12
|
Classifier: Intended Audience :: Information Technology
|
|
12
13
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -16,20 +17,30 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Typing :: Typed
|
|
19
21
|
Requires-Dist: antlr4-python3-runtime (==4.9.2)
|
|
20
22
|
Requires-Dist: bottleneck (>=1.3.4,<2.0.0)
|
|
21
23
|
Requires-Dist: duckdb (>=1.1.1,<2.0.0)
|
|
22
24
|
Requires-Dist: networkx (>=2.8.8,<3.0.0)
|
|
23
|
-
Requires-Dist: numba (>=0.60.0,<0.61.0)
|
|
24
25
|
Requires-Dist: numexpr (>=2.9.0,<3.0.0)
|
|
25
26
|
Requires-Dist: pandas (>=2.1.4,<3.0.0)
|
|
26
|
-
Requires-Dist: pyarrow (>=17.0.0,<18.0.0)
|
|
27
27
|
Requires-Dist: s3fs (>=2024.9.0,<2025.0.0)
|
|
28
28
|
Requires-Dist: sqlglot (>=22.2.0,<23.0.0)
|
|
29
|
+
Project-URL: Authors, https://github.com/Meaningful-Data/vtlengine/graphs/contributors
|
|
30
|
+
Project-URL: Documentation, https://docs.vtlengine.meaningfuldata.eu
|
|
31
|
+
Project-URL: IssueTracker, https://github.com/Meaningful-Data/vtlengine/issues
|
|
32
|
+
Project-URL: MeaningfulData, https://www.meaningfuldata.eu/
|
|
33
|
+
Project-URL: Repository, https://github.com/Meaningful-Data/vtlengine
|
|
29
34
|
Description-Content-Type: text/markdown
|
|
30
35
|
|
|
31
36
|
# VTL Engine
|
|
32
37
|
|
|
38
|
+
| | |
|
|
39
|
+
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
40
|
+
| Testing | [](https://github.com/Meaningful-Data/vtlengine/actions/workflows/testing.yml) |
|
|
41
|
+
| Package | [](https://pypi.org/project/vtlengine/) |
|
|
42
|
+
| License | [](https://github.com/Meaningful-Data/vtlengine/blob/main/LICENSE.md) |
|
|
43
|
+
|
|
33
44
|
## Introduction
|
|
34
45
|
|
|
35
46
|
The VTL Engine is a Python library for validating and running VTL scripts.
|
|
@@ -67,7 +78,8 @@ Any action with VTL requires the following elements as input:
|
|
|
67
78
|
* **VTL Script**: Is the VTL to be executed, which includes the transformation scheme, as well as de
|
|
68
79
|
User Defined Operators, Hierarchical Rulesets and Datapoint Rulesets. It is provided as a string
|
|
69
80
|
or as a Path object to a vtl file.
|
|
70
|
-
* **Data structures** : Provides the structure of the input artifacts of the VTL script, according
|
|
81
|
+
* **Data structures** : Provides the structure of the input artifacts of the VTL script, according
|
|
82
|
+
to
|
|
71
83
|
the VTL Information model. Given that the current version doesn't prescribe a standard format for
|
|
72
84
|
providing the information, the VTL Engine is implementing a JSON format that can be found here.
|
|
73
85
|
Data Structures can be provided as Dictionaries or as Paths to JSON files. It is possible to have
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# VTL Engine
|
|
2
2
|
|
|
3
|
+
| | |
|
|
4
|
+
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
5
|
+
| Testing | [](https://github.com/Meaningful-Data/vtlengine/actions/workflows/testing.yml) |
|
|
6
|
+
| Package | [](https://pypi.org/project/vtlengine/) |
|
|
7
|
+
| License | [](https://github.com/Meaningful-Data/vtlengine/blob/main/LICENSE.md) |
|
|
8
|
+
|
|
3
9
|
## Introduction
|
|
4
10
|
|
|
5
11
|
The VTL Engine is a Python library for validating and running VTL scripts.
|
|
@@ -37,7 +43,8 @@ Any action with VTL requires the following elements as input:
|
|
|
37
43
|
* **VTL Script**: Is the VTL to be executed, which includes the transformation scheme, as well as de
|
|
38
44
|
User Defined Operators, Hierarchical Rulesets and Datapoint Rulesets. It is provided as a string
|
|
39
45
|
or as a Path object to a vtl file.
|
|
40
|
-
* **Data structures** : Provides the structure of the input artifacts of the VTL script, according
|
|
46
|
+
* **Data structures** : Provides the structure of the input artifacts of the VTL script, according
|
|
47
|
+
to
|
|
41
48
|
the VTL Information model. Given that the current version doesn't prescribe a standard format for
|
|
42
49
|
providing the information, the VTL Engine is implementing a JSON format that can be found here.
|
|
43
50
|
Data Structures can be provided as Dictionaries or as Paths to JSON files. It is possible to have
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "vtlengine"
|
|
3
|
+
version = "1.0.3"
|
|
4
|
+
description = "Run and Validate VTL Scripts"
|
|
5
|
+
authors = ["MeaningfulData <info@meaningfuldata.eu>"]
|
|
6
|
+
license = "AGPL-3.0"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 5 - Production/Stable",
|
|
11
|
+
"Intended Audience :: Developers",
|
|
12
|
+
"Intended Audience :: Information Technology",
|
|
13
|
+
"Intended Audience :: Science/Research",
|
|
14
|
+
"Typing :: Typed"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
keywords = ['vtl', 'sdmx', 'vtlengine', 'Validation and Transformation Language']
|
|
18
|
+
|
|
19
|
+
[tool.poetry.urls]
|
|
20
|
+
Repository = 'https://github.com/Meaningful-Data/vtlengine'
|
|
21
|
+
Documentation = 'https://docs.vtlengine.meaningfuldata.eu'
|
|
22
|
+
MeaningfulData = 'https://www.meaningfuldata.eu/'
|
|
23
|
+
IssueTracker = 'https://github.com/Meaningful-Data/vtlengine/issues'
|
|
24
|
+
Authors = 'https://github.com/Meaningful-Data/vtlengine/graphs/contributors'
|
|
25
|
+
|
|
26
|
+
[tool.poetry.dependencies]
|
|
27
|
+
python = "^3.10"
|
|
28
|
+
# PyPi dependencies
|
|
29
|
+
duckdb = "^1.1.1"
|
|
30
|
+
#numba = "^0.60.0"
|
|
31
|
+
s3fs = "^2024.9.0"
|
|
32
|
+
|
|
33
|
+
# APT dependencies
|
|
34
|
+
antlr4-python3-runtime = "4.9.2"
|
|
35
|
+
networkx = "^2.8.8"
|
|
36
|
+
numexpr = "^2.9.0"
|
|
37
|
+
pandas = "^2.1.4"
|
|
38
|
+
bottleneck = "^1.3.4"
|
|
39
|
+
sqlglot = "^22.2.0"
|
|
40
|
+
|
|
41
|
+
[tool.poetry.dev-dependencies]
|
|
42
|
+
pytest = "^7.3"
|
|
43
|
+
pytest-cov = "^5.0.0"
|
|
44
|
+
line-profiler-pycharm = "^1.2.0"
|
|
45
|
+
sphinx = "^7.4"
|
|
46
|
+
sphinx-rtd-theme = "^2.0.0"
|
|
47
|
+
mypy = "^1.11.2"
|
|
48
|
+
pandas-stubs = "^2.2.3.241009"
|
|
49
|
+
stubs = "^1.0.0"
|
|
50
|
+
toml = "^0.10.2"
|
|
51
|
+
ruff = "^0.7.1"
|
|
52
|
+
|
|
53
|
+
[tool.ruff]
|
|
54
|
+
line-length = 100
|
|
55
|
+
lint.mccabe.max-complexity = 20
|
|
56
|
+
lint.select = [
|
|
57
|
+
"B", "B9", "C", "C4", "D", "E", "F", "I", "PT", "S", "SIM", "W"
|
|
58
|
+
]
|
|
59
|
+
# TODO: check S608 (duckdb querys)
|
|
60
|
+
lint.ignore = ["B023", "B028", "B904", "C403", "D100", "D101", "D102", "D103", "D104", "D105",
|
|
61
|
+
"D107", "D200", "D201", "D202", "D203", "D205", "D209", "D212", "D213", "D301",
|
|
62
|
+
"D400", "D401", "D404", "D411", "D413", "D415", "D419", "E203", "S320", "S608"]
|
|
63
|
+
lint.exclude = ["*/Grammar/*"]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.lint.per-file-ignores]
|
|
66
|
+
"tests/*" = ["S101", "PT006", "PT012", "PT013", "E501", "W605"]
|
|
67
|
+
"src/vtlengine/*" = ["E712"]
|
|
68
|
+
|
|
69
|
+
[tool.mypy]
|
|
70
|
+
files = "src"
|
|
71
|
+
exclude = "src/vtlengine/AST/.*"
|
|
72
|
+
disallow_untyped_defs = true
|
|
73
|
+
disallow_untyped_calls = true
|
|
74
|
+
ignore_errors = false
|
|
75
|
+
no_implicit_optional = true
|
|
76
|
+
show_column_numbers = true
|
|
77
|
+
strict_equality = true
|
|
78
|
+
strict_optional = true
|
|
79
|
+
strict = true
|
|
80
|
+
enable_error_code = [
|
|
81
|
+
"ignore-without-code",
|
|
82
|
+
"redundant-expr",
|
|
83
|
+
"truthy-bool",
|
|
84
|
+
]
|
|
85
|
+
warn_return_any = false
|
|
86
|
+
|
|
87
|
+
[build-system]
|
|
88
|
+
requires = ["poetry-core"]
|
|
89
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Any, Dict, List, Optional, Union
|
|
5
5
|
|
|
6
6
|
import pandas as pd
|
|
7
7
|
from s3fs import S3FileSystem # type: ignore[import-untyped]
|
|
8
8
|
|
|
9
9
|
from vtlengine.AST import PersistentAssignment, Start
|
|
10
10
|
from vtlengine.DataTypes import SCALAR_TYPES
|
|
11
|
-
from vtlengine.
|
|
12
|
-
from vtlengine.files.parser import
|
|
11
|
+
from vtlengine.Exceptions import check_key
|
|
12
|
+
from vtlengine.files.parser import _fill_dataset_empty_data, _validate_pandas
|
|
13
|
+
from vtlengine.Model import (
|
|
14
|
+
Component,
|
|
15
|
+
Dataset,
|
|
16
|
+
ExternalRoutine,
|
|
17
|
+
Role,
|
|
18
|
+
Role_keys,
|
|
19
|
+
Scalar,
|
|
20
|
+
ValueDomain,
|
|
21
|
+
)
|
|
13
22
|
|
|
14
23
|
base_path = Path(__file__).parent
|
|
15
24
|
filepath_VTL = base_path / "data" / "vtl"
|
|
@@ -30,15 +39,17 @@ def _load_dataset_from_structure(structures: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
30
39
|
if "datasets" in structures:
|
|
31
40
|
for dataset_json in structures["datasets"]:
|
|
32
41
|
dataset_name = dataset_json["name"]
|
|
33
|
-
components = {
|
|
34
|
-
|
|
42
|
+
components = {}
|
|
43
|
+
|
|
44
|
+
for component in dataset_json["DataStructure"]:
|
|
45
|
+
check_key("data_type", SCALAR_TYPES.keys(), component["type"])
|
|
46
|
+
check_key("role", Role_keys, component["role"])
|
|
47
|
+
components[component["name"]] = Component(
|
|
35
48
|
name=component["name"],
|
|
36
49
|
data_type=SCALAR_TYPES[component["type"]],
|
|
37
50
|
role=Role(component["role"]),
|
|
38
51
|
nullable=component["nullable"],
|
|
39
52
|
)
|
|
40
|
-
for component in dataset_json["DataStructure"]
|
|
41
|
-
}
|
|
42
53
|
|
|
43
54
|
datasets[dataset_name] = Dataset(name=dataset_name, components=components, data=None)
|
|
44
55
|
if "scalars" in structures:
|
|
@@ -208,7 +219,7 @@ def load_datasets_with_data(data_structures: Any, datapoints: Optional[Any] = No
|
|
|
208
219
|
return datasets, None
|
|
209
220
|
# Handling dictionary of paths
|
|
210
221
|
dict_datapoints = _load_datapoints_path(datapoints)
|
|
211
|
-
for dataset_name,
|
|
222
|
+
for dataset_name, _ in dict_datapoints.items():
|
|
212
223
|
if dataset_name not in datasets:
|
|
213
224
|
raise Exception(f"Not found dataset {dataset_name}")
|
|
214
225
|
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import Any,
|
|
2
|
+
from typing import Any, Dict, List, Optional, Union
|
|
3
3
|
|
|
4
4
|
import pandas as pd
|
|
5
5
|
from antlr4 import CommonTokenStream, InputStream # type: ignore[import-untyped]
|
|
6
6
|
from antlr4.error.ErrorListener import ErrorListener # type: ignore[import-untyped]
|
|
7
7
|
|
|
8
8
|
from vtlengine.API._InternalApi import (
|
|
9
|
-
|
|
9
|
+
_check_output_folder,
|
|
10
|
+
_return_only_persistent_datasets,
|
|
10
11
|
load_datasets,
|
|
11
|
-
load_value_domains,
|
|
12
|
-
load_external_routines,
|
|
13
12
|
load_datasets_with_data,
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
load_external_routines,
|
|
14
|
+
load_value_domains,
|
|
15
|
+
load_vtl,
|
|
16
16
|
)
|
|
17
17
|
from vtlengine.AST import Start
|
|
18
18
|
from vtlengine.AST.ASTConstructor import ASTVisitor
|
|
19
19
|
from vtlengine.AST.DAG import DAGAnalyzer
|
|
20
20
|
from vtlengine.AST.Grammar.lexer import Lexer
|
|
21
21
|
from vtlengine.AST.Grammar.parser import Parser
|
|
22
|
-
from vtlengine.Interpreter import InterpreterAnalyzer
|
|
23
22
|
from vtlengine.files.output._time_period_representation import (
|
|
24
|
-
format_time_period_external_representation,
|
|
25
23
|
TimePeriodRepresentation,
|
|
24
|
+
format_time_period_external_representation,
|
|
26
25
|
)
|
|
26
|
+
from vtlengine.Interpreter import InterpreterAnalyzer
|
|
27
27
|
|
|
28
28
|
pd.options.mode.chained_assignment = None
|
|
29
29
|
|
|
@@ -78,7 +78,7 @@ def create_ast(text: str) -> Start:
|
|
|
78
78
|
stream = _lexer(text)
|
|
79
79
|
cst = _parser(stream)
|
|
80
80
|
visitor = ASTVisitor()
|
|
81
|
-
ast = visitor.
|
|
81
|
+
ast = visitor.visitStart(cst)
|
|
82
82
|
DAGAnalyzer.createDAG(ast)
|
|
83
83
|
return ast
|
|
84
84
|
|
|
@@ -10,18 +10,18 @@ Node Creator.
|
|
|
10
10
|
from antlr4.tree.Tree import TerminalNodeImpl
|
|
11
11
|
|
|
12
12
|
from vtlengine.AST import (
|
|
13
|
-
Start,
|
|
14
|
-
Assignment,
|
|
15
|
-
PersistentAssignment,
|
|
16
|
-
Operator,
|
|
17
13
|
Argument,
|
|
14
|
+
Assignment,
|
|
15
|
+
DefIdentifier,
|
|
16
|
+
DPRule,
|
|
18
17
|
DPRuleset,
|
|
19
18
|
HRBinOp,
|
|
20
|
-
DPRule,
|
|
21
|
-
HRuleset,
|
|
22
|
-
DefIdentifier,
|
|
23
19
|
HRule,
|
|
20
|
+
HRuleset,
|
|
24
21
|
HRUnOp,
|
|
22
|
+
Operator,
|
|
23
|
+
PersistentAssignment,
|
|
24
|
+
Start,
|
|
25
25
|
)
|
|
26
26
|
from vtlengine.AST.ASTConstructorModules.Expr import Expr
|
|
27
27
|
from vtlengine.AST.ASTConstructorModules.ExprComponents import ExprComp
|
|
@@ -30,8 +30,7 @@ from vtlengine.AST.ASTDataExchange import de_ruleset_elements
|
|
|
30
30
|
from vtlengine.AST.Grammar.parser import Parser
|
|
31
31
|
from vtlengine.AST.VtlVisitor import VtlVisitor
|
|
32
32
|
from vtlengine.Exceptions import SemanticError
|
|
33
|
-
from vtlengine.Model import
|
|
34
|
-
|
|
33
|
+
from vtlengine.Model import Component, Dataset, Scalar
|
|
35
34
|
|
|
36
35
|
# pylint: disable=unreachable,expression-not-assigned
|
|
37
36
|
# pylint: disable=assignment-from-no-return
|
|
@@ -280,19 +279,13 @@ class ASTVisitor(VtlVisitor):
|
|
|
280
279
|
for erCode_name in ctx_list
|
|
281
280
|
if isinstance(erCode_name, Parser.ErCodeContext)
|
|
282
281
|
]
|
|
283
|
-
if len(er_code) == 0
|
|
284
|
-
er_code = None
|
|
285
|
-
else:
|
|
286
|
-
er_code = er_code[0]
|
|
282
|
+
er_code = None if len(er_code) == 0 else er_code[0]
|
|
287
283
|
er_level = [
|
|
288
284
|
Terminals().visitErLevel(erLevel_name)
|
|
289
285
|
for erLevel_name in ctx_list
|
|
290
286
|
if isinstance(erLevel_name, Parser.ErLevelContext)
|
|
291
287
|
]
|
|
292
|
-
if len(er_level) == 0
|
|
293
|
-
er_level = None
|
|
294
|
-
else:
|
|
295
|
-
er_level = er_level[0]
|
|
288
|
+
er_level = None if len(er_level) == 0 else er_level[0]
|
|
296
289
|
|
|
297
290
|
return DPRule(name=rule_name, rule=rule_node, erCode=er_code, erLevel=er_level)
|
|
298
291
|
|
|
@@ -317,11 +310,7 @@ class ASTVisitor(VtlVisitor):
|
|
|
317
310
|
for element in ctx_list
|
|
318
311
|
if isinstance(element, Parser.ScalarItemContext)
|
|
319
312
|
]
|
|
320
|
-
|
|
321
|
-
if len(argument_default) == 0:
|
|
322
|
-
argument_default = None
|
|
323
|
-
else:
|
|
324
|
-
argument_default = argument_default[0]
|
|
313
|
+
argument_default = None if len(argument_default) == 0 else argument_default[0]
|
|
325
314
|
|
|
326
315
|
if isinstance(argument_type, (Dataset, Component, Scalar)):
|
|
327
316
|
argument_type.name = argument_name.value
|
|
@@ -375,10 +364,7 @@ class ASTVisitor(VtlVisitor):
|
|
|
375
364
|
if isinstance(valueDomain, TerminalNodeImpl)
|
|
376
365
|
and valueDomain.getSymbol().type == Parser.VALUE_DOMAIN
|
|
377
366
|
]
|
|
378
|
-
if len(value_domain) != 0
|
|
379
|
-
kind = "ValuedomainID"
|
|
380
|
-
else:
|
|
381
|
-
kind = "DatasetID"
|
|
367
|
+
kind = "ValuedomainID" if len(value_domain) != 0 else "DatasetID"
|
|
382
368
|
|
|
383
369
|
conditions = [
|
|
384
370
|
self.visitValueDomainSignature(vtlsig)
|
|
@@ -408,8 +394,8 @@ class ASTVisitor(VtlVisitor):
|
|
|
408
394
|
# TODO Support for valueDomainSignature.
|
|
409
395
|
def visitValueDomainSignature(self, ctx: Parser.ValueDomainSignatureContext):
|
|
410
396
|
"""
|
|
411
|
-
valueDomainSignature: CONDITION IDENTIFIER (AS IDENTIFIER)? (',' IDENTIFIER (AS IDENTIFIER)?)* ;
|
|
412
|
-
"""
|
|
397
|
+
valueDomainSignature: CONDITION IDENTIFIER (AS IDENTIFIER)? (',' IDENTIFIER (AS IDENTIFIER)?)* ;
|
|
398
|
+
""" # noqa E501
|
|
413
399
|
# AST_ASTCONSTRUCTOR.7
|
|
414
400
|
ctx_list = list(ctx.getChildren())
|
|
415
401
|
component_nodes = [
|
|
@@ -458,28 +444,22 @@ class ASTVisitor(VtlVisitor):
|
|
|
458
444
|
for erCode_name in ctx_list
|
|
459
445
|
if isinstance(erCode_name, Parser.ErCodeContext)
|
|
460
446
|
]
|
|
461
|
-
if len(er_code) == 0
|
|
462
|
-
er_code = None
|
|
463
|
-
else:
|
|
464
|
-
er_code = er_code[0]
|
|
447
|
+
er_code = None if len(er_code) == 0 else er_code[0]
|
|
465
448
|
er_level = [
|
|
466
449
|
Terminals().visitErLevel(erLevel_name)
|
|
467
450
|
for erLevel_name in ctx_list
|
|
468
451
|
if isinstance(erLevel_name, Parser.ErLevelContext)
|
|
469
452
|
]
|
|
470
|
-
if len(er_level) == 0
|
|
471
|
-
er_level = None
|
|
472
|
-
else:
|
|
473
|
-
er_level = er_level[0]
|
|
453
|
+
er_level = None if len(er_level) == 0 else er_level[0]
|
|
474
454
|
|
|
475
455
|
return HRule(name=rule_name, rule=rule_node, erCode=er_code, erLevel=er_level)
|
|
476
456
|
|
|
477
457
|
def visitCodeItemRelation(self, ctx: Parser.CodeItemRelationContext):
|
|
478
458
|
"""
|
|
479
|
-
codeItemRelation: ( WHEN expr THEN )? codeItemRef codeItemRelationClause (codeItemRelationClause)* ;
|
|
480
|
-
( WHEN exprComponent THEN )? codetemRef=valueDomainValue comparisonOperand? codeItemRelationClause (codeItemRelationClause)*
|
|
459
|
+
codeItemRelation: ( WHEN expr THEN )? codeItemRef codeItemRelationClause (codeItemRelationClause)* ;
|
|
460
|
+
( WHEN exprComponent THEN )? codetemRef=valueDomainValue comparisonOperand? codeItemRelationClause (codeItemRelationClause)*
|
|
481
461
|
|
|
482
|
-
"""
|
|
462
|
+
""" # noqa E501
|
|
483
463
|
|
|
484
464
|
ctx_list = list(ctx.getChildren())
|
|
485
465
|
|
|
@@ -531,8 +511,8 @@ class ASTVisitor(VtlVisitor):
|
|
|
531
511
|
|
|
532
512
|
def visitCodeItemRelationClause(self, ctx: Parser.CodeItemRelationClauseContext):
|
|
533
513
|
"""
|
|
534
|
-
(opAdd=( PLUS | MINUS ))? rightCodeItem=valueDomainValue ( QLPAREN rightCondition=exprComponent QRPAREN )?
|
|
535
|
-
"""
|
|
514
|
+
(opAdd=( PLUS | MINUS ))? rightCodeItem=valueDomainValue ( QLPAREN rightCondition=exprComponent QRPAREN )?
|
|
515
|
+
""" # noqa E501
|
|
536
516
|
ctx_list = list(ctx.getChildren())
|
|
537
517
|
|
|
538
518
|
expr = [expr for expr in ctx_list if isinstance(expr, Parser.ExprContext)]
|
|
@@ -552,13 +532,13 @@ class ASTVisitor(VtlVisitor):
|
|
|
552
532
|
|
|
553
533
|
code_item = DefIdentifier(value=value, kind="CodeItemID")
|
|
554
534
|
if right_condition:
|
|
555
|
-
|
|
535
|
+
code_item._right_condition = right_condition[0]
|
|
556
536
|
|
|
557
537
|
return HRBinOp(left=None, op=op, right=code_item)
|
|
558
538
|
else:
|
|
559
539
|
value = Terminals().visitValueDomainValue(ctx_list[0])
|
|
560
540
|
code_item = DefIdentifier(value=value, kind="CodeItemID")
|
|
561
541
|
if right_condition:
|
|
562
|
-
|
|
542
|
+
code_item._right_condition = right_condition[0]
|
|
563
543
|
|
|
564
544
|
return code_item
|