pydpm_xl 0.1.39rc32__py3-none-any.whl → 0.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.
- py_dpm/__init__.py +1 -1
- py_dpm/api/__init__.py +58 -189
- py_dpm/api/dpm/__init__.py +20 -0
- py_dpm/api/{data_dictionary.py → dpm/data_dictionary.py} +903 -984
- py_dpm/api/dpm/explorer.py +236 -0
- py_dpm/api/dpm/hierarchical_queries.py +142 -0
- py_dpm/api/{migration.py → dpm/migration.py} +16 -19
- py_dpm/api/{operation_scopes.py → dpm/operation_scopes.py} +319 -267
- py_dpm/api/dpm_xl/__init__.py +25 -0
- py_dpm/api/{ast_generator.py → dpm_xl/ast_generator.py} +3 -3
- py_dpm/api/{complete_ast.py → dpm_xl/complete_ast.py} +191 -167
- py_dpm/api/dpm_xl/semantic.py +354 -0
- py_dpm/api/{syntax.py → dpm_xl/syntax.py} +6 -5
- py_dpm/api/explorer.py +4 -0
- py_dpm/api/semantic.py +30 -306
- py_dpm/cli/__init__.py +9 -0
- py_dpm/{client.py → cli/main.py} +8 -8
- py_dpm/dpm/__init__.py +11 -0
- py_dpm/{models.py → dpm/models.py} +112 -88
- py_dpm/dpm/queries/base.py +100 -0
- py_dpm/dpm/queries/basic_objects.py +33 -0
- py_dpm/dpm/queries/explorer_queries.py +352 -0
- py_dpm/dpm/queries/filters.py +139 -0
- py_dpm/dpm/queries/glossary.py +45 -0
- py_dpm/dpm/queries/hierarchical_queries.py +838 -0
- py_dpm/dpm/queries/tables.py +133 -0
- py_dpm/dpm/utils.py +356 -0
- py_dpm/dpm_xl/__init__.py +8 -0
- py_dpm/dpm_xl/ast/__init__.py +14 -0
- py_dpm/{AST/ASTConstructor.py → dpm_xl/ast/constructor.py} +6 -6
- py_dpm/{AST/MLGeneration.py → dpm_xl/ast/ml_generation.py} +137 -87
- py_dpm/{AST/ModuleAnalyzer.py → dpm_xl/ast/module_analyzer.py} +7 -7
- py_dpm/{AST/ModuleDependencies.py → dpm_xl/ast/module_dependencies.py} +56 -41
- py_dpm/{AST/ASTObjects.py → dpm_xl/ast/nodes.py} +1 -1
- py_dpm/{AST/check_operands.py → dpm_xl/ast/operands.py} +16 -13
- py_dpm/{AST/ASTTemplate.py → dpm_xl/ast/template.py} +2 -2
- py_dpm/{AST/WhereClauseChecker.py → dpm_xl/ast/where_clause.py} +2 -2
- py_dpm/dpm_xl/grammar/__init__.py +18 -0
- py_dpm/dpm_xl/operators/__init__.py +19 -0
- py_dpm/{Operators/AggregateOperators.py → dpm_xl/operators/aggregate.py} +7 -7
- py_dpm/{Operators/NumericOperators.py → dpm_xl/operators/arithmetic.py} +6 -6
- py_dpm/{Operators/Operator.py → dpm_xl/operators/base.py} +5 -5
- py_dpm/{Operators/BooleanOperators.py → dpm_xl/operators/boolean.py} +5 -5
- py_dpm/{Operators/ClauseOperators.py → dpm_xl/operators/clause.py} +8 -8
- py_dpm/{Operators/ComparisonOperators.py → dpm_xl/operators/comparison.py} +5 -5
- py_dpm/{Operators/ConditionalOperators.py → dpm_xl/operators/conditional.py} +7 -7
- py_dpm/{Operators/StringOperators.py → dpm_xl/operators/string.py} +5 -5
- py_dpm/{Operators/TimeOperators.py → dpm_xl/operators/time.py} +6 -6
- py_dpm/{semantics/SemanticAnalyzer.py → dpm_xl/semantic_analyzer.py} +168 -68
- py_dpm/{semantics/Symbols.py → dpm_xl/symbols.py} +3 -3
- py_dpm/dpm_xl/types/__init__.py +13 -0
- py_dpm/{DataTypes/TypePromotion.py → dpm_xl/types/promotion.py} +2 -2
- py_dpm/{DataTypes/ScalarTypes.py → dpm_xl/types/scalar.py} +2 -2
- py_dpm/dpm_xl/utils/__init__.py +14 -0
- py_dpm/{data_handlers.py → dpm_xl/utils/data_handlers.py} +2 -2
- py_dpm/{Utils → dpm_xl/utils}/operands_mapping.py +1 -1
- py_dpm/{Utils → dpm_xl/utils}/operator_mapping.py +8 -8
- py_dpm/{OperationScopes/OperationScopeService.py → dpm_xl/utils/scopes_calculator.py} +148 -58
- py_dpm/{Utils/ast_serialization.py → dpm_xl/utils/serialization.py} +2 -2
- py_dpm/dpm_xl/validation/__init__.py +12 -0
- py_dpm/{Utils/ValidationsGenerationUtils.py → dpm_xl/validation/generation_utils.py} +2 -3
- py_dpm/{ValidationsGeneration/PropertiesConstraintsProcessor.py → dpm_xl/validation/property_constraints.py} +56 -21
- py_dpm/{ValidationsGeneration/auxiliary_functions.py → dpm_xl/validation/utils.py} +2 -2
- py_dpm/{ValidationsGeneration/VariantsProcessor.py → dpm_xl/validation/variants.py} +149 -55
- py_dpm/exceptions/__init__.py +23 -0
- py_dpm/{Exceptions → exceptions}/exceptions.py +7 -2
- pydpm_xl-0.2.0.dist-info/METADATA +278 -0
- pydpm_xl-0.2.0.dist-info/RECORD +88 -0
- pydpm_xl-0.2.0.dist-info/entry_points.txt +2 -0
- py_dpm/Exceptions/__init__.py +0 -0
- py_dpm/OperationScopes/__init__.py +0 -0
- py_dpm/Operators/__init__.py +0 -0
- py_dpm/Utils/__init__.py +0 -0
- py_dpm/Utils/utils.py +0 -2
- py_dpm/ValidationsGeneration/Utils.py +0 -364
- py_dpm/ValidationsGeneration/__init__.py +0 -0
- py_dpm/api/data_dictionary_validation.py +0 -614
- py_dpm/db_utils.py +0 -221
- py_dpm/grammar/__init__.py +0 -0
- py_dpm/grammar/dist/__init__.py +0 -0
- py_dpm/grammar/dpm_xlLexer.g4 +0 -437
- py_dpm/grammar/dpm_xlParser.g4 +0 -263
- py_dpm/semantics/DAG/DAGAnalyzer.py +0 -158
- py_dpm/semantics/DAG/__init__.py +0 -0
- py_dpm/semantics/__init__.py +0 -0
- py_dpm/views/data_types.sql +0 -12
- py_dpm/views/datapoints.sql +0 -65
- py_dpm/views/hierarchy_operand_reference.sql +0 -11
- py_dpm/views/hierarchy_preconditions.sql +0 -13
- py_dpm/views/hierarchy_variables.sql +0 -26
- py_dpm/views/hierarchy_variables_context.sql +0 -14
- py_dpm/views/key_components.sql +0 -18
- py_dpm/views/module_from_table.sql +0 -11
- py_dpm/views/open_keys.sql +0 -13
- py_dpm/views/operation_info.sql +0 -27
- py_dpm/views/operation_list.sql +0 -18
- py_dpm/views/operations_versions_from_module_version.sql +0 -30
- py_dpm/views/precondition_info.sql +0 -17
- py_dpm/views/report_type_operand_reference_info.sql +0 -18
- py_dpm/views/subcategory_info.sql +0 -17
- py_dpm/views/table_info.sql +0 -19
- pydpm_xl-0.1.39rc32.dist-info/METADATA +0 -53
- pydpm_xl-0.1.39rc32.dist-info/RECORD +0 -96
- pydpm_xl-0.1.39rc32.dist-info/entry_points.txt +0 -2
- /py_dpm/{AST → cli/commands}/__init__.py +0 -0
- /py_dpm/{migration.py → dpm/migration.py} +0 -0
- /py_dpm/{AST/ASTVisitor.py → dpm_xl/ast/visitor.py} +0 -0
- /py_dpm/{DataTypes → dpm_xl/grammar/generated}/__init__.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlLexer.interp +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlLexer.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlLexer.tokens +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParser.interp +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParser.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParser.tokens +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParserListener.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/dpm_xlParserVisitor.py +0 -0
- /py_dpm/{grammar/dist → dpm_xl/grammar/generated}/listeners.py +0 -0
- /py_dpm/{DataTypes/TimeClasses.py → dpm_xl/types/time.py} +0 -0
- /py_dpm/{Utils → dpm_xl/utils}/tokens.py +0 -0
- /py_dpm/{Exceptions → exceptions}/messages.py +0 -0
- {pydpm_xl-0.1.39rc32.dist-info → pydpm_xl-0.2.0.dist-info}/WHEEL +0 -0
- {pydpm_xl-0.1.39rc32.dist-info → pydpm_xl-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {pydpm_xl-0.1.39rc32.dist-info → pydpm_xl-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -1,39 +1,51 @@
|
|
|
1
1
|
from abc import ABC
|
|
2
2
|
|
|
3
|
-
from py_dpm.
|
|
4
|
-
from py_dpm.
|
|
5
|
-
from py_dpm.
|
|
6
|
-
from py_dpm.
|
|
7
|
-
from py_dpm.models import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
from py_dpm.dpm_xl.ast.nodes import *
|
|
4
|
+
from py_dpm.dpm_xl.ast.template import ASTTemplate
|
|
5
|
+
from py_dpm.dpm_xl.ast.where_clause import WhereClauseChecker
|
|
6
|
+
from py_dpm.exceptions import exceptions
|
|
7
|
+
from py_dpm.dpm.models import (
|
|
8
|
+
TableVersion,
|
|
9
|
+
VariableVersion,
|
|
10
|
+
ViewDatapoints,
|
|
11
|
+
ViewModules,
|
|
12
|
+
ItemCategory,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
operand_elements = ["table", "rows", "cols", "sheets", "default", "interval"]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def filter_datapoints_df(df, table, table_info: dict, release_id: int = None):
|
|
19
|
+
""" """
|
|
20
|
+
mapping_dictionary = {
|
|
21
|
+
"rows": "row_code",
|
|
22
|
+
"cols": "column_code",
|
|
23
|
+
"sheets": "sheet_code",
|
|
24
|
+
}
|
|
25
|
+
df = df[df["table_code"] == table]
|
|
16
26
|
for k, v in table_info.items():
|
|
17
27
|
if v is not None:
|
|
18
|
-
if
|
|
19
|
-
low_limit, high_limit = v[0].split(
|
|
28
|
+
if "-" in v[0]:
|
|
29
|
+
low_limit, high_limit = v[0].split("-")
|
|
20
30
|
df = df[(df[mapping_dictionary[k]].between(low_limit, high_limit))]
|
|
21
|
-
elif v[0] ==
|
|
31
|
+
elif v[0] == "*":
|
|
22
32
|
continue
|
|
23
33
|
else:
|
|
24
34
|
df = df[(df[mapping_dictionary[k]].isin(v))]
|
|
25
35
|
|
|
26
36
|
if release_id:
|
|
27
|
-
df = df[df[
|
|
37
|
+
df = df[df["release_id"] == release_id]
|
|
28
38
|
return df
|
|
29
39
|
|
|
40
|
+
|
|
30
41
|
def filter_module_by_table_df(df, table):
|
|
31
42
|
"""
|
|
32
43
|
Returns a list of modules that contain the table
|
|
33
44
|
"""
|
|
34
|
-
module_list = df[df[
|
|
45
|
+
module_list = df[df["table_code"] == table]["module_code"].tolist()
|
|
35
46
|
return module_list
|
|
36
47
|
|
|
48
|
+
|
|
37
49
|
class ModuleDependencies(ASTTemplate, ABC):
|
|
38
50
|
def __init__(self, session, ast, release_id, date, module_ref, is_scripting=False):
|
|
39
51
|
self.release_id = release_id
|
|
@@ -55,7 +67,7 @@ class ModuleDependencies(ASTTemplate, ABC):
|
|
|
55
67
|
self.is_scripting = is_scripting
|
|
56
68
|
|
|
57
69
|
self.session = session
|
|
58
|
-
self.time_period =
|
|
70
|
+
self.time_period = "t" # TODO
|
|
59
71
|
self.date = date
|
|
60
72
|
self.modules = {}
|
|
61
73
|
self.from_time_shift = False
|
|
@@ -63,7 +75,6 @@ class ModuleDependencies(ASTTemplate, ABC):
|
|
|
63
75
|
super().__init__()
|
|
64
76
|
self.visit(self.AST)
|
|
65
77
|
|
|
66
|
-
|
|
67
78
|
# Start of visiting nodes
|
|
68
79
|
def visit_WithExpression(self, node: WithExpression):
|
|
69
80
|
if node.partial_selection.is_table_group:
|
|
@@ -78,17 +89,16 @@ class ModuleDependencies(ASTTemplate, ABC):
|
|
|
78
89
|
|
|
79
90
|
if self.partial_selection:
|
|
80
91
|
for attribute in operand_elements:
|
|
81
|
-
if
|
|
92
|
+
if (
|
|
93
|
+
getattr(node, attribute, None) is None
|
|
94
|
+
and not getattr(self.partial_selection, attribute, None) is None
|
|
95
|
+
):
|
|
82
96
|
setattr(node, attribute, getattr(self.partial_selection, attribute))
|
|
83
97
|
|
|
84
98
|
if not node.table:
|
|
85
99
|
raise exceptions.SemanticError("1-4", table=node.table)
|
|
86
100
|
|
|
87
|
-
table_info = {
|
|
88
|
-
'rows': node.rows,
|
|
89
|
-
'cols': node.cols,
|
|
90
|
-
'sheets': node.sheets
|
|
91
|
-
}
|
|
101
|
+
table_info = {"rows": node.rows, "cols": node.cols, "sheets": node.sheets}
|
|
92
102
|
|
|
93
103
|
if node.table not in self.tables:
|
|
94
104
|
self.tables[node.table] = table_info
|
|
@@ -100,17 +110,16 @@ class ModuleDependencies(ASTTemplate, ABC):
|
|
|
100
110
|
# self.operands[node.table].append(node)
|
|
101
111
|
|
|
102
112
|
# Variables full
|
|
103
|
-
variables_full = ViewDatapoints.get_filtered_datapoints(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
release_id=self.release_id)
|
|
113
|
+
variables_full = ViewDatapoints.get_filtered_datapoints(
|
|
114
|
+
self.session, node.table, table_info, release_id=self.release_id
|
|
115
|
+
)
|
|
107
116
|
# variables_full = ViewDatapoints.get_table_data(self.session, node.table, table_info['rows'], table_info['cols'], table_info['sheets'],
|
|
108
117
|
# self.release_id)
|
|
109
118
|
|
|
110
119
|
if variables_full.empty:
|
|
111
120
|
raise exceptions.SemanticError("1-5", open_keys=table_info)
|
|
112
121
|
|
|
113
|
-
final_list = variables_full[
|
|
122
|
+
final_list = variables_full["variable_id"].to_list()
|
|
114
123
|
# Here change table for module or modules
|
|
115
124
|
modules = ViewModules().get_all_modules(self.session) # TODO
|
|
116
125
|
modules = filter_module_by_table_df(modules, node.table)
|
|
@@ -137,35 +146,41 @@ class ModuleDependencies(ASTTemplate, ABC):
|
|
|
137
146
|
full_name = f"{node.table}:{self.time_period}"
|
|
138
147
|
self.full_operands[full_name] = final_list
|
|
139
148
|
|
|
140
|
-
|
|
141
149
|
def visit_Dimension(self, node: Dimension):
|
|
142
150
|
if node.dimension_code not in self.dimension_codes:
|
|
143
151
|
self.dimension_codes.append(node.dimension_code)
|
|
144
|
-
if not ItemCategory.get_property_from_code(
|
|
152
|
+
if not ItemCategory.get_property_from_code(
|
|
153
|
+
node.dimension_code, self.session
|
|
154
|
+
):
|
|
145
155
|
raise exceptions.SemanticError("1-5", open_keys=node.dimension_code)
|
|
146
156
|
|
|
147
157
|
def visit_VarRef(self, node: VarRef):
|
|
148
|
-
if not VariableVersion.check_variable_exists(
|
|
149
|
-
|
|
158
|
+
if not VariableVersion.check_variable_exists(
|
|
159
|
+
self.session, node.variable, self.release_id
|
|
160
|
+
):
|
|
161
|
+
raise exceptions.SemanticError("1-3", variable=node.variable)
|
|
150
162
|
|
|
151
163
|
def visit_PreconditionItem(self, node: PreconditionItem):
|
|
152
164
|
|
|
153
165
|
if self.is_scripting:
|
|
154
|
-
raise exceptions.SemanticError(
|
|
166
|
+
raise exceptions.SemanticError("6-3", precondition=node.variable_id)
|
|
155
167
|
|
|
156
|
-
if not TableVersion.check_table_exists(
|
|
168
|
+
if not TableVersion.check_table_exists(
|
|
169
|
+
self.session, node.variable_id, self.release_id
|
|
170
|
+
):
|
|
157
171
|
raise exceptions.SemanticError("1-3", variable=node.variable_id)
|
|
158
172
|
|
|
159
173
|
self.preconditions = True
|
|
160
174
|
|
|
161
175
|
def visit_Scalar(self, node: Scalar):
|
|
162
|
-
if node.item and node.scalar_type ==
|
|
176
|
+
if node.item and node.scalar_type == "Item":
|
|
163
177
|
if node.item not in self.items:
|
|
164
178
|
self.items.append(node.item)
|
|
165
|
-
if not ItemCategory.get_item_category_id_from_signature(
|
|
179
|
+
if not ItemCategory.get_item_category_id_from_signature(
|
|
180
|
+
node.item, self.session
|
|
181
|
+
):
|
|
166
182
|
raise exceptions.SemanticError("1-1", items=node.item)
|
|
167
183
|
|
|
168
|
-
|
|
169
184
|
def visit_WhereClauseOp(self, node: WhereClauseOp):
|
|
170
185
|
self.visit(node.operand)
|
|
171
186
|
checker = WhereClauseChecker()
|
|
@@ -178,7 +193,7 @@ class ModuleDependencies(ASTTemplate, ABC):
|
|
|
178
193
|
period_indicator = node.period_indicator
|
|
179
194
|
shift_number = node.shift_number
|
|
180
195
|
# compute new time period
|
|
181
|
-
if period_indicator not in (
|
|
196
|
+
if period_indicator not in ("A", "Q", "M", "W", "D"):
|
|
182
197
|
raise ValueError("Period indicator is not valid")
|
|
183
198
|
if "-" in shift_number:
|
|
184
199
|
new_time_period = f"t+{period_indicator}{shift_number}"
|
|
@@ -255,7 +255,7 @@ class VarID(AST):
|
|
|
255
255
|
|
|
256
256
|
# First check if type attribute is set (from semantic validation)
|
|
257
257
|
if hasattr(self, 'type') and self.type is not None:
|
|
258
|
-
from py_dpm.
|
|
258
|
+
from py_dpm.dpm_xl.types.scalar import Number
|
|
259
259
|
if isinstance(self.type, Number):
|
|
260
260
|
interval_value = self.interval if self.interval is not None else False
|
|
261
261
|
else:
|
|
@@ -6,7 +6,7 @@ import warnings
|
|
|
6
6
|
# Suppress pandas UserWarning about SQLAlchemy connection types
|
|
7
7
|
warnings.filterwarnings("ignore", message=".*pandas only supports SQLAlchemy.*")
|
|
8
8
|
|
|
9
|
-
from py_dpm.
|
|
9
|
+
from py_dpm.dpm_xl.ast.nodes import (
|
|
10
10
|
Dimension,
|
|
11
11
|
GetOp,
|
|
12
12
|
OperationRef,
|
|
@@ -19,12 +19,12 @@ from py_dpm.AST.ASTObjects import (
|
|
|
19
19
|
WhereClauseOp,
|
|
20
20
|
WithExpression,
|
|
21
21
|
)
|
|
22
|
-
from py_dpm.
|
|
23
|
-
from py_dpm.
|
|
24
|
-
from py_dpm.
|
|
25
|
-
from py_dpm.
|
|
26
|
-
from py_dpm.
|
|
27
|
-
from py_dpm.models import (
|
|
22
|
+
from py_dpm.dpm_xl.ast.template import ASTTemplate
|
|
23
|
+
from py_dpm.dpm_xl.ast.where_clause import WhereClauseChecker
|
|
24
|
+
from py_dpm.dpm_xl.types.scalar import Integer, Mixed, Number, ScalarFactory
|
|
25
|
+
from py_dpm.exceptions import exceptions
|
|
26
|
+
from py_dpm.exceptions.exceptions import SemanticError
|
|
27
|
+
from py_dpm.dpm.models import (
|
|
28
28
|
ItemCategory,
|
|
29
29
|
Operation,
|
|
30
30
|
VariableVersion,
|
|
@@ -35,10 +35,10 @@ from py_dpm.models import (
|
|
|
35
35
|
TableVersion,
|
|
36
36
|
TableVersionHeader,
|
|
37
37
|
Header,
|
|
38
|
-
filter_by_release,
|
|
39
38
|
)
|
|
40
|
-
from py_dpm.
|
|
41
|
-
from py_dpm.
|
|
39
|
+
from py_dpm.dpm.queries.filters import filter_by_release
|
|
40
|
+
from py_dpm.dpm_xl.utils.operands_mapping import generate_new_label, set_operand_label
|
|
41
|
+
from py_dpm.dpm_xl.utils.data_handlers import filter_all_data
|
|
42
42
|
|
|
43
43
|
operand_elements = ["table", "rows", "cols", "sheets", "default", "interval"]
|
|
44
44
|
|
|
@@ -208,16 +208,19 @@ class OperandsChecking(ASTTemplate, ABC):
|
|
|
208
208
|
# Apply release filter
|
|
209
209
|
query = filter_by_release(
|
|
210
210
|
query,
|
|
211
|
+
self.release_id,
|
|
211
212
|
TableVersion.startreleaseid,
|
|
212
213
|
TableVersion.endreleaseid,
|
|
213
|
-
self.release_id,
|
|
214
214
|
)
|
|
215
215
|
|
|
216
216
|
# Execute query and convert to DataFrame
|
|
217
|
-
from py_dpm.models import
|
|
217
|
+
from py_dpm.dpm.models import (
|
|
218
|
+
_compile_query_for_pandas,
|
|
219
|
+
_read_sql_with_connection,
|
|
220
|
+
)
|
|
218
221
|
|
|
219
222
|
compiled_query = _compile_query_for_pandas(query.statement, self.session)
|
|
220
|
-
df_headers =
|
|
223
|
+
df_headers = _read_sql_with_connection(compiled_query, self.session)
|
|
221
224
|
|
|
222
225
|
for table in table_codes:
|
|
223
226
|
table_headers = df_headers[df_headers["Code"] == table]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from py_dpm.
|
|
1
|
+
from py_dpm.dpm_xl.ast.nodes import AggregationOp, BinOp, ComplexNumericOp, CondExpr, Constant, Dimension, FilterOp, GetOp, GroupingClause, \
|
|
2
2
|
OperationRef, ParExpr, PersistentAssignment, PreconditionItem, PropertyReference, RenameOp, Scalar, Set, Start, SubOp, TemporaryAssignment, \
|
|
3
3
|
TimeShiftOp, UnaryOp, VarID, VarRef, WhereClauseOp, WithExpression
|
|
4
|
-
from py_dpm.
|
|
4
|
+
from py_dpm.dpm_xl.ast.visitor import NodeVisitor
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class ASTTemplate(NodeVisitor):
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DPM-XL Grammar
|
|
3
|
+
|
|
4
|
+
ANTLR4 grammar definitions and generated parsers for DPM-XL expressions.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
# Import generated parser and lexer
|
|
8
|
+
from py_dpm.dpm_xl.grammar.generated.dpm_xlLexer import dpm_xlLexer
|
|
9
|
+
from py_dpm.dpm_xl.grammar.generated.dpm_xlParser import dpm_xlParser
|
|
10
|
+
from py_dpm.dpm_xl.grammar.generated.dpm_xlParserVisitor import dpm_xlParserVisitor
|
|
11
|
+
from py_dpm.dpm_xl.grammar.generated.dpm_xlParserListener import dpm_xlParserListener
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"dpm_xlLexer",
|
|
15
|
+
"dpm_xlParser",
|
|
16
|
+
"dpm_xlParserVisitor",
|
|
17
|
+
"dpm_xlParserListener",
|
|
18
|
+
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DPM-XL Operators
|
|
3
|
+
|
|
4
|
+
Operator implementations for DPM-XL expressions.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from py_dpm.dpm_xl.operators.base import *
|
|
8
|
+
from py_dpm.dpm_xl.operators.arithmetic import *
|
|
9
|
+
from py_dpm.dpm_xl.operators.boolean import *
|
|
10
|
+
from py_dpm.dpm_xl.operators.comparison import *
|
|
11
|
+
from py_dpm.dpm_xl.operators.conditional import *
|
|
12
|
+
from py_dpm.dpm_xl.operators.aggregate import *
|
|
13
|
+
from py_dpm.dpm_xl.operators.string import *
|
|
14
|
+
from py_dpm.dpm_xl.operators.time import *
|
|
15
|
+
from py_dpm.dpm_xl.operators.clause import *
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
# Re-export will be handled by import *
|
|
19
|
+
]
|
|
@@ -2,15 +2,15 @@ import warnings
|
|
|
2
2
|
|
|
3
3
|
import pandas as pd
|
|
4
4
|
|
|
5
|
-
from py_dpm.
|
|
6
|
-
from py_dpm.
|
|
7
|
-
from py_dpm.
|
|
8
|
-
from py_dpm.
|
|
9
|
-
from py_dpm.
|
|
10
|
-
from py_dpm.
|
|
5
|
+
from py_dpm.dpm_xl.types.scalar import Integer, Number, ScalarFactory
|
|
6
|
+
from py_dpm.dpm_xl.types.promotion import unary_implicit_type_promotion
|
|
7
|
+
from py_dpm.exceptions import exceptions
|
|
8
|
+
from py_dpm.dpm_xl.operators.base import Operator, Binary, Unary, Complex
|
|
9
|
+
from py_dpm.dpm_xl.utils import tokens
|
|
10
|
+
from py_dpm.dpm_xl.symbols import RecordSet
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class AggregateOperator(
|
|
13
|
+
class AggregateOperator(Unary):
|
|
14
14
|
"""
|
|
15
15
|
Aggregate operators involve all operators with a Recordset and a Grouping clause.
|
|
16
16
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import math
|
|
2
2
|
import operator
|
|
3
3
|
|
|
4
|
-
from py_dpm.
|
|
5
|
-
from py_dpm.
|
|
6
|
-
from py_dpm.
|
|
4
|
+
from py_dpm.dpm_xl.types.scalar import Number
|
|
5
|
+
from py_dpm.dpm_xl.operators.base import Operator, Binary, Unary, Complex
|
|
6
|
+
from py_dpm.dpm_xl.utils import tokens
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
class Unary(
|
|
9
|
+
class Unary(Unary):
|
|
10
10
|
op = None
|
|
11
11
|
type_to_check = Number
|
|
12
12
|
return_type = None
|
|
@@ -49,7 +49,7 @@ class SquareRoot(Unary):
|
|
|
49
49
|
interval_allowed: bool = False
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
class NumericBinary(
|
|
52
|
+
class NumericBinary(Binary):
|
|
53
53
|
type_to_check = Number
|
|
54
54
|
interval_allowed:bool = True
|
|
55
55
|
|
|
@@ -88,7 +88,7 @@ class Logarithm(NumericBinary):
|
|
|
88
88
|
interval_allowed:bool = False
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
class NumericComplex(
|
|
91
|
+
class NumericComplex(Complex):
|
|
92
92
|
type_to_check = Number
|
|
93
93
|
interval_allowed:bool = True
|
|
94
94
|
|
|
@@ -3,13 +3,13 @@ from typing import Union
|
|
|
3
3
|
|
|
4
4
|
import pandas as pd
|
|
5
5
|
|
|
6
|
-
from py_dpm.
|
|
7
|
-
from py_dpm.
|
|
6
|
+
from py_dpm.dpm_xl.types.scalar import Mixed, Number, ScalarFactory
|
|
7
|
+
from py_dpm.dpm_xl.types.promotion import binary_implicit_type_promotion, binary_implicit_type_promotion_with_mixed_types, \
|
|
8
8
|
check_operator, \
|
|
9
9
|
unary_implicit_type_promotion, unary_implicit_type_promotion_with_mixed_types
|
|
10
|
-
from py_dpm.
|
|
11
|
-
from py_dpm.
|
|
12
|
-
from py_dpm.
|
|
10
|
+
from py_dpm.exceptions.exceptions import SemanticError
|
|
11
|
+
from py_dpm.dpm_xl.utils.operands_mapping import generate_new_label, set_operand_label
|
|
12
|
+
from py_dpm.dpm_xl.symbols import ConstantOperand, FactComponent, RecordSet, Scalar, ScalarSet, Structure
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class Operator:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import operator
|
|
2
2
|
|
|
3
|
-
from py_dpm.
|
|
4
|
-
from py_dpm.
|
|
5
|
-
from py_dpm.
|
|
3
|
+
from py_dpm.dpm_xl.types.scalar import Boolean
|
|
4
|
+
from py_dpm.dpm_xl.operators.base import Operator, Binary, Unary, Complex
|
|
5
|
+
from py_dpm.dpm_xl.utils import tokens
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class Binary(
|
|
8
|
+
class Binary(Binary):
|
|
9
9
|
type_to_check = Boolean
|
|
10
10
|
|
|
11
11
|
|
|
@@ -24,7 +24,7 @@ class Xor(Binary):
|
|
|
24
24
|
py_op = operator.xor
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
class Not(
|
|
27
|
+
class Not(Unary):
|
|
28
28
|
type_to_check = Boolean
|
|
29
29
|
op = tokens.NOT
|
|
30
30
|
py_op = operator.not_
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
from typing import List
|
|
2
2
|
|
|
3
|
-
from py_dpm.
|
|
4
|
-
from py_dpm.
|
|
5
|
-
from py_dpm.
|
|
6
|
-
from py_dpm.
|
|
7
|
-
from py_dpm.
|
|
8
|
-
from py_dpm.
|
|
9
|
-
from py_dpm.
|
|
10
|
-
from py_dpm.
|
|
3
|
+
from py_dpm.dpm_xl.types.scalar import ScalarFactory
|
|
4
|
+
from py_dpm.dpm_xl.types.promotion import unary_implicit_type_promotion
|
|
5
|
+
from py_dpm.exceptions import exceptions
|
|
6
|
+
from py_dpm.dpm_xl.operators.conditional import ConditionalOperator
|
|
7
|
+
from py_dpm.dpm_xl.operators.base import Binary, Operator
|
|
8
|
+
from py_dpm.dpm_xl.utils import tokens
|
|
9
|
+
from py_dpm.dpm_xl.utils.operands_mapping import generate_new_label, set_operand_label
|
|
10
|
+
from py_dpm.dpm_xl.symbols import FactComponent, RecordSet
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class ClauseOperator(Operator):
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import operator
|
|
2
2
|
import re
|
|
3
3
|
|
|
4
|
-
from py_dpm.
|
|
5
|
-
from py_dpm.
|
|
6
|
-
from py_dpm.
|
|
4
|
+
from py_dpm.dpm_xl.types.scalar import Boolean, String
|
|
5
|
+
from py_dpm.dpm_xl.operators.base import Operator, Binary, Unary, Complex
|
|
6
|
+
from py_dpm.dpm_xl.utils import tokens
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
class IsNull(
|
|
9
|
+
class IsNull(Unary):
|
|
10
10
|
op = tokens.ISNULL
|
|
11
11
|
py_op = operator.truth
|
|
12
12
|
do_not_check_with_return_type = True
|
|
13
13
|
return_type = Boolean
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
class Binary(
|
|
16
|
+
class Binary(Binary):
|
|
17
17
|
do_not_check_with_return_type = True
|
|
18
18
|
return_type = Boolean
|
|
19
19
|
|
|
@@ -3,14 +3,14 @@ from typing import Union
|
|
|
3
3
|
|
|
4
4
|
import pandas as pd
|
|
5
5
|
|
|
6
|
-
from py_dpm.
|
|
7
|
-
from py_dpm.
|
|
6
|
+
from py_dpm.dpm_xl.types.scalar import Mixed, ScalarFactory
|
|
7
|
+
from py_dpm.dpm_xl.types.promotion import binary_implicit_type_promotion, binary_implicit_type_promotion_with_mixed_types, \
|
|
8
8
|
unary_implicit_type_promotion
|
|
9
|
-
from py_dpm.
|
|
10
|
-
from py_dpm.
|
|
11
|
-
from py_dpm.
|
|
12
|
-
from py_dpm.
|
|
13
|
-
from py_dpm.
|
|
9
|
+
from py_dpm.exceptions import exceptions
|
|
10
|
+
from py_dpm.exceptions.exceptions import SemanticError
|
|
11
|
+
from py_dpm.dpm_xl.operators.base import Binary, Operator
|
|
12
|
+
from py_dpm.dpm_xl.utils import tokens
|
|
13
|
+
from py_dpm.dpm_xl.symbols import ConstantOperand, RecordSet, Scalar, Structure
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class ConditionalOperator(Operator):
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import operator
|
|
2
2
|
|
|
3
|
-
from py_dpm.
|
|
4
|
-
from py_dpm.
|
|
5
|
-
from py_dpm.
|
|
3
|
+
from py_dpm.dpm_xl.types.scalar import Integer, String
|
|
4
|
+
from py_dpm.dpm_xl.operators.base import Operator, Binary, Unary, Complex
|
|
5
|
+
from py_dpm.dpm_xl.utils import tokens
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class Unary(
|
|
8
|
+
class Unary(Unary):
|
|
9
9
|
op = None
|
|
10
10
|
type_to_check = String
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
class Binary(
|
|
13
|
+
class Binary(Binary):
|
|
14
14
|
op = None
|
|
15
15
|
type_to_check = String
|
|
16
16
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from typing import Union
|
|
2
2
|
|
|
3
|
-
from py_dpm.
|
|
4
|
-
from py_dpm.
|
|
5
|
-
from py_dpm.
|
|
6
|
-
from py_dpm.
|
|
7
|
-
from py_dpm.
|
|
8
|
-
from py_dpm.
|
|
3
|
+
from py_dpm.dpm_xl.types.scalar import ScalarFactory, TimeInterval
|
|
4
|
+
from py_dpm.dpm_xl.types.promotion import unary_implicit_type_promotion
|
|
5
|
+
from py_dpm.exceptions import exceptions
|
|
6
|
+
from py_dpm.dpm_xl.operators.base import Operator
|
|
7
|
+
from py_dpm.dpm_xl.utils import tokens
|
|
8
|
+
from py_dpm.dpm_xl.symbols import ConstantOperand, RecordSet, Scalar
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class TimeShift(Operator):
|