pytrilogy 0.0.3.97__py3-none-any.whl → 0.0.3.98__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 pytrilogy might be problematic. Click here for more details.
- {pytrilogy-0.0.3.97.dist-info → pytrilogy-0.0.3.98.dist-info}/METADATA +1 -1
- {pytrilogy-0.0.3.97.dist-info → pytrilogy-0.0.3.98.dist-info}/RECORD +18 -17
- trilogy/__init__.py +1 -1
- trilogy/core/functions.py +1 -1
- trilogy/core/models/execute.py +0 -1
- trilogy/core/processing/node_generators/node_merge_node.py +109 -5
- trilogy/core/validation/concept.py +9 -0
- trilogy/core/validation/environment.py +1 -0
- trilogy/dialect/common.py +2 -10
- trilogy/dialect/metadata.py +1 -1
- trilogy/executor.py +7 -0
- trilogy/parsing/parse_engine.py +2 -2
- trilogy/parsing/render.py +2 -2
- trilogy/std/metric.preql +15 -0
- {pytrilogy-0.0.3.97.dist-info → pytrilogy-0.0.3.98.dist-info}/WHEEL +0 -0
- {pytrilogy-0.0.3.97.dist-info → pytrilogy-0.0.3.98.dist-info}/entry_points.txt +0 -0
- {pytrilogy-0.0.3.97.dist-info → pytrilogy-0.0.3.98.dist-info}/licenses/LICENSE.md +0 -0
- {pytrilogy-0.0.3.97.dist-info → pytrilogy-0.0.3.98.dist-info}/top_level.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
pytrilogy-0.0.3.
|
|
2
|
-
trilogy/__init__.py,sha256=
|
|
1
|
+
pytrilogy-0.0.3.98.dist-info/licenses/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
|
|
2
|
+
trilogy/__init__.py,sha256=NSBY37z8wVkVSFPfHPo0BTvi3hO7KMw7ENbaoX9PqBY,303
|
|
3
3
|
trilogy/constants.py,sha256=SSsRMg9HTou259nMKAw-rJNBgzkWjQ3QIQXcrq9i5Kk,1717
|
|
4
4
|
trilogy/engine.py,sha256=3MiADf5MKcmxqiHBuRqiYdsXiLj7oitDfVvXvHrfjkA,2178
|
|
5
|
-
trilogy/executor.py,sha256=
|
|
5
|
+
trilogy/executor.py,sha256=0yggm9Ejl1DFELUtRaPxbaU5mpKqYMHZlzSMXOFmODE,16111
|
|
6
6
|
trilogy/parser.py,sha256=o4cfk3j3yhUFoiDKq9ZX_GjBF3dKhDjXEwb63rcBkBM,293
|
|
7
7
|
trilogy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
trilogy/render.py,sha256=qQWwduymauOlB517UtM-VGbVe8Cswa4UJub5aGbSO6c,1512
|
|
@@ -15,7 +15,7 @@ trilogy/core/env_processor.py,sha256=H-rr2ALj31l5oh3FqeI47Qju6OOfiXBacXNJGNZ92zQ
|
|
|
15
15
|
trilogy/core/environment_helpers.py,sha256=TRlqVctqIRBxzfjRBmpQsAVoiCcsEKBhG1B6PUE0l1M,12743
|
|
16
16
|
trilogy/core/ergonomics.py,sha256=e-7gE29vPLFdg0_A1smQ7eOrUwKl5VYdxRSTddHweRA,1631
|
|
17
17
|
trilogy/core/exceptions.py,sha256=fI16oTNCVMMAJFSn2AFzZVapzsF5M9WbdN5e5UixwXc,2807
|
|
18
|
-
trilogy/core/functions.py,sha256=
|
|
18
|
+
trilogy/core/functions.py,sha256=oY-F0hsA9vp1ZipGTyx4QVtz_x83Ekk-lkHv6mMkHVQ,33095
|
|
19
19
|
trilogy/core/graph_models.py,sha256=4EWFTHGfYd72zvS2HYoV6hm7nMC_VEd7vWr6txY-ig0,3400
|
|
20
20
|
trilogy/core/internal.py,sha256=r9QagDB2GvpqlyD_I7VrsfbVfIk5mnok2znEbv72Aa4,2681
|
|
21
21
|
trilogy/core/optimization.py,sha256=ojpn-p79lr03SSVQbbw74iPCyoYpDYBmj1dbZ3oXCjI,8860
|
|
@@ -28,7 +28,7 @@ trilogy/core/models/build_environment.py,sha256=mpx7MKGc60fnZLVdeLi2YSREy7eQbQYy
|
|
|
28
28
|
trilogy/core/models/core.py,sha256=EofJ8-kltNr_7oFhyCPqauVX1bSJzJI5xOp0eMP_vlA,12892
|
|
29
29
|
trilogy/core/models/datasource.py,sha256=wogTevZ-9CyUW2a8gjzqMCieircxi-J5lkI7EOAZnck,9596
|
|
30
30
|
trilogy/core/models/environment.py,sha256=hwTIRnJgaHUdCYof7U5A9NPitGZ2s9yxqiW5O2SaJ9Y,28759
|
|
31
|
-
trilogy/core/models/execute.py,sha256=
|
|
31
|
+
trilogy/core/models/execute.py,sha256=lQTpiuNhBT4In-oQ76ImgIoTdUbs4mmyd0J0iTOZOdw,42105
|
|
32
32
|
trilogy/core/optimizations/__init__.py,sha256=YH2-mGXZnVDnBcWVi8vTbrdw7Qs5TivG4h38rH3js_I,290
|
|
33
33
|
trilogy/core/optimizations/base_optimization.py,sha256=gzDOKImoFn36k7XBD3ysEYDnbnb6vdVIztUfFQZsGnM,513
|
|
34
34
|
trilogy/core/optimizations/inline_datasource.py,sha256=2sWNRpoRInnTgo9wExVT_r9RfLAQHI57reEV5cGHUcg,4329
|
|
@@ -49,7 +49,7 @@ trilogy/core/processing/node_generators/filter_node.py,sha256=ArBsQJl-4fWBJWCE28
|
|
|
49
49
|
trilogy/core/processing/node_generators/group_node.py,sha256=8HJ1lkOvIXfX3xoS2IMbM_wCu_mT0J_hQ7xnTaxsVlo,6611
|
|
50
50
|
trilogy/core/processing/node_generators/group_to_node.py,sha256=jKcNCDOY6fNblrdZwaRU0sbUSr9H0moQbAxrGgX6iGA,3832
|
|
51
51
|
trilogy/core/processing/node_generators/multiselect_node.py,sha256=GWV5yLmKTe1yyPhN60RG1Rnrn4ktfn9lYYXi_FVU4UI,7061
|
|
52
|
-
trilogy/core/processing/node_generators/node_merge_node.py,sha256=
|
|
52
|
+
trilogy/core/processing/node_generators/node_merge_node.py,sha256=cBcZm3AUfx4K70MIhU0T9iKMxw_qZRVFhQ0i6qMQeoQ,21999
|
|
53
53
|
trilogy/core/processing/node_generators/recursive_node.py,sha256=l5zdh0dURKwmAy8kK4OpMtZfyUEQRk6N-PwSWIyBpSM,2468
|
|
54
54
|
trilogy/core/processing/node_generators/rowset_node.py,sha256=5L5u6xz1In8EaHQdcYgR2si-tz9WB9YLXURo4AkUT9A,6630
|
|
55
55
|
trilogy/core/processing/node_generators/select_merge_node.py,sha256=KQvGoNT5ZBWQ_caEomRTtG1PKZC7OPT4PKfY0QmwMGE,22270
|
|
@@ -77,19 +77,19 @@ trilogy/core/statements/common.py,sha256=VnVLULQg1TJLNUFzJaROT1tsf2ewk3IpuhvZaP3
|
|
|
77
77
|
trilogy/core/statements/execute.py,sha256=kiwJcVeMa4wZR-xLfM2oYOJ9DeyJkP8An38WFyJxktM,2413
|
|
78
78
|
trilogy/core/validation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
79
|
trilogy/core/validation/common.py,sha256=Sd-towAX1uSDe3dK51FcVtIwVrMhayEwdHqhzeJHro0,4776
|
|
80
|
-
trilogy/core/validation/concept.py,sha256=
|
|
80
|
+
trilogy/core/validation/concept.py,sha256=PM2BxBxLvuBScSWZMPsDZVcOblDil5pNT0pHLcLhdPA,5242
|
|
81
81
|
trilogy/core/validation/datasource.py,sha256=d9AQNcukIRgN2spItPsXFiNtlZva-lDnfei3i06yQCE,6489
|
|
82
|
-
trilogy/core/validation/environment.py,sha256=
|
|
82
|
+
trilogy/core/validation/environment.py,sha256=ymvhQyt7jLK641JAAIQkqjQaAmr9C5022ILzYvDgPP0,2835
|
|
83
83
|
trilogy/core/validation/fix.py,sha256=Z818UFNLxndMTLiyhB3doLxIfnOZ-16QGvVFWuD7UsA,3750
|
|
84
84
|
trilogy/dialect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
85
85
|
trilogy/dialect/base.py,sha256=0QVHv4F0t3_gRQrZ0woFoUNKu7vaXGo-BG1l47CZUKc,49698
|
|
86
86
|
trilogy/dialect/bigquery.py,sha256=XS3hpybeowgfrOrkycAigAF3NX2YUzTzfgE6f__2fT4,4316
|
|
87
|
-
trilogy/dialect/common.py,sha256=
|
|
87
|
+
trilogy/dialect/common.py,sha256=_MarnMWRBn3VcNt3k5VUdFrwH6oHzGdNQquSpHNLq4o,5644
|
|
88
88
|
trilogy/dialect/config.py,sha256=olnyeVU5W5T6b9-dMeNAnvxuPlyc2uefb7FRME094Ec,3834
|
|
89
89
|
trilogy/dialect/dataframe.py,sha256=RUbNgReEa9g3pL6H7fP9lPTrAij5pkqedpZ99D8_5AE,1522
|
|
90
90
|
trilogy/dialect/duckdb.py,sha256=JoUvQ19WvgxoaJkGLM7DPXOd1H0394k3vBiblksQzOI,5631
|
|
91
91
|
trilogy/dialect/enums.py,sha256=FRNYQ5-w-B6-X0yXKNU5g9GowsMlERFogTC5u2nxL_s,4740
|
|
92
|
-
trilogy/dialect/metadata.py,sha256=
|
|
92
|
+
trilogy/dialect/metadata.py,sha256=p_V-MYPQ2iR6fcTjagnptCIWtsZe4fTfoS_iXpavPzY,7098
|
|
93
93
|
trilogy/dialect/postgres.py,sha256=el2PKwfyvWGk5EZtLudqAH5ewLitY1sFHJiocBSyxyM,3393
|
|
94
94
|
trilogy/dialect/presto.py,sha256=k1IaeilR3nzPC9Hp7jlAdzJ7TsuxB3LQTBQ28MYE7O8,3715
|
|
95
95
|
trilogy/dialect/snowflake.py,sha256=T6_mKfhpDazB1xQxqFLS2AJwzwzBcPYY6_qxRnAtFBs,3326
|
|
@@ -104,8 +104,8 @@ trilogy/parsing/common.py,sha256=550-L0444GUuBFdiDWkOg_DxnMXtcJFUMES2R5zlwik,310
|
|
|
104
104
|
trilogy/parsing/config.py,sha256=Z-DaefdKhPDmSXLgg5V4pebhSB0h590vI0_VtHnlukI,111
|
|
105
105
|
trilogy/parsing/exceptions.py,sha256=Xwwsv2C9kSNv2q-HrrKC1f60JNHShXcCMzstTSEbiCw,154
|
|
106
106
|
trilogy/parsing/helpers.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
107
|
-
trilogy/parsing/parse_engine.py,sha256
|
|
108
|
-
trilogy/parsing/render.py,sha256=
|
|
107
|
+
trilogy/parsing/parse_engine.py,sha256=-3_-EoiciWGOlylKurSPlG7gYSbScjneBup7ZvjDz-c,81800
|
|
108
|
+
trilogy/parsing/render.py,sha256=tqB3GlGk3bX6AbkJjvADad2QH6n63nw1kgrpjzLX2tI,20520
|
|
109
109
|
trilogy/parsing/trilogy.lark,sha256=rM4WleeyGhoRgU-FOGcaeHOzZcYVxN4f13e_3B4OeLQ,16389
|
|
110
110
|
trilogy/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
111
111
|
trilogy/scripts/trilogy.py,sha256=1L0XrH4mVHRt1C9T1HnaDv2_kYEfbWTb5_-cBBke79w,3774
|
|
@@ -113,12 +113,13 @@ trilogy/std/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
113
113
|
trilogy/std/date.preql,sha256=HWZm4t4HWyxr5geWRsY05RnHBVDMci8z8YA2cu0-OOw,188
|
|
114
114
|
trilogy/std/display.preql,sha256=nm7lox87Xf6lBvXCVCS6x2HskguMKzndEBucJ5pktzk,175
|
|
115
115
|
trilogy/std/geography.preql,sha256=1A9Sq5PPMBnEPPf7f-rPVYxJfsnWpQ8oV_k4Fm3H2dU,675
|
|
116
|
+
trilogy/std/metric.preql,sha256=DRECGhkMyqfit5Fl4Ut9zbWrJuSMI1iO9HikuyoBpE0,421
|
|
116
117
|
trilogy/std/money.preql,sha256=XWwvAV3WxBsHX9zfptoYRnBigcfYwrYtBHXTME0xJuQ,2082
|
|
117
118
|
trilogy/std/net.preql,sha256=WZCuvH87_rZntZiuGJMmBDMVKkdhTtxeHOkrXNwJ1EE,416
|
|
118
119
|
trilogy/std/ranking.preql,sha256=LDoZrYyz4g3xsII9XwXfmstZD-_92i1Eox1UqkBIfi8,83
|
|
119
120
|
trilogy/std/report.preql,sha256=LbV-XlHdfw0jgnQ8pV7acG95xrd1-p65fVpiIc-S7W4,202
|
|
120
|
-
pytrilogy-0.0.3.
|
|
121
|
-
pytrilogy-0.0.3.
|
|
122
|
-
pytrilogy-0.0.3.
|
|
123
|
-
pytrilogy-0.0.3.
|
|
124
|
-
pytrilogy-0.0.3.
|
|
121
|
+
pytrilogy-0.0.3.98.dist-info/METADATA,sha256=8FfhicjKv1X47j0nL557PM_b1TisXXmAz3DG2B-PBdI,11683
|
|
122
|
+
pytrilogy-0.0.3.98.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
123
|
+
pytrilogy-0.0.3.98.dist-info/entry_points.txt,sha256=ewBPU2vLnVexZVnB-NrVj-p3E-4vukg83Zk8A55Wp2w,56
|
|
124
|
+
pytrilogy-0.0.3.98.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
|
|
125
|
+
pytrilogy-0.0.3.98.dist-info/RECORD,,
|
trilogy/__init__.py
CHANGED
trilogy/core/functions.py
CHANGED
|
@@ -427,7 +427,7 @@ FUNCTION_REGISTRY: dict[FunctionType, FunctionConfig] = {
|
|
|
427
427
|
{DataType.STRING},
|
|
428
428
|
],
|
|
429
429
|
output_purpose=Purpose.PROPERTY,
|
|
430
|
-
output_type=DataType.
|
|
430
|
+
output_type=DataType.STRING,
|
|
431
431
|
arg_count=2,
|
|
432
432
|
),
|
|
433
433
|
FunctionType.SUBSTRING: FunctionConfig(
|
trilogy/core/models/execute.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from itertools import combinations
|
|
2
|
+
from typing import Callable, List, Optional
|
|
2
3
|
|
|
3
4
|
import networkx as nx
|
|
4
5
|
from networkx.algorithms import approximation as ax
|
|
@@ -11,7 +12,12 @@ from trilogy.core.graph_models import (
|
|
|
11
12
|
concept_to_node,
|
|
12
13
|
prune_sources_for_conditions,
|
|
13
14
|
)
|
|
14
|
-
from trilogy.core.models.build import
|
|
15
|
+
from trilogy.core.models.build import (
|
|
16
|
+
BuildConcept,
|
|
17
|
+
BuildConditional,
|
|
18
|
+
BuildGrain,
|
|
19
|
+
BuildWhereClause,
|
|
20
|
+
)
|
|
15
21
|
from trilogy.core.models.build_environment import BuildEnvironment
|
|
16
22
|
from trilogy.core.processing.nodes import History, MergeNode, StrategyNode
|
|
17
23
|
from trilogy.core.processing.utility import padding
|
|
@@ -29,7 +35,10 @@ def filter_pseudonyms_for_source(
|
|
|
29
35
|
if edge in pseudonyms:
|
|
30
36
|
lengths = {}
|
|
31
37
|
for n in edge:
|
|
32
|
-
|
|
38
|
+
try:
|
|
39
|
+
lengths[n] = nx.shortest_path_length(ds_graph, node, n)
|
|
40
|
+
except nx.NetworkXNoPath:
|
|
41
|
+
lengths[n] = 999
|
|
33
42
|
to_remove.add(max(lengths, key=lambda x: lengths.get(x, 0)))
|
|
34
43
|
for node in to_remove:
|
|
35
44
|
ds_graph.remove_node(node)
|
|
@@ -84,12 +93,104 @@ def extract_ds_components(
|
|
|
84
93
|
return graphs
|
|
85
94
|
|
|
86
95
|
|
|
96
|
+
def prune_and_merge(
|
|
97
|
+
G: nx.DiGraph,
|
|
98
|
+
keep_node_lambda: Callable[[str], bool],
|
|
99
|
+
) -> nx.DiGraph:
|
|
100
|
+
"""
|
|
101
|
+
Prune nodes of one type and create direct connections between remaining nodes.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
G: NetworkX graph
|
|
105
|
+
keep_node_type: The node type to keep
|
|
106
|
+
node_type_attr: Attribute name that stores node type
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
New graph with only keep_node_type nodes and merged connections
|
|
110
|
+
"""
|
|
111
|
+
# Get nodes to keep
|
|
112
|
+
nodes_to_keep = [n for n in G.nodes if keep_node_lambda(n)]
|
|
113
|
+
# Create new graph
|
|
114
|
+
new_graph = G.subgraph(nodes_to_keep).copy()
|
|
115
|
+
|
|
116
|
+
# Find paths between nodes to keep through removed nodes
|
|
117
|
+
nodes_to_remove = [n for n in G.nodes() if n not in nodes_to_keep]
|
|
118
|
+
|
|
119
|
+
for node_pair in combinations(nodes_to_keep, 2):
|
|
120
|
+
n1, n2 = node_pair
|
|
121
|
+
|
|
122
|
+
# Check if there's a path through removed nodes
|
|
123
|
+
try:
|
|
124
|
+
path = nx.shortest_path(G, n1, n2)
|
|
125
|
+
# If path exists and goes through nodes we're removing
|
|
126
|
+
if len(path) > 2 or any(node in nodes_to_remove for node in path[1:-1]):
|
|
127
|
+
new_graph.add_edge(n1, n2)
|
|
128
|
+
except nx.NetworkXNoPath:
|
|
129
|
+
continue
|
|
130
|
+
|
|
131
|
+
return new_graph
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def reinject_common_join_keys_v2(
|
|
135
|
+
G: ReferenceGraph,
|
|
136
|
+
final: nx.DiGraph,
|
|
137
|
+
nodelist: list[str],
|
|
138
|
+
synonyms: set[str] = set(),
|
|
139
|
+
) -> bool:
|
|
140
|
+
# when we've discovered a concept join, for each pair of ds nodes
|
|
141
|
+
# check if they have more keys in common
|
|
142
|
+
# and inject those to discovery as join conditions
|
|
143
|
+
def is_ds_node(n: str) -> bool:
|
|
144
|
+
return n.startswith("ds~")
|
|
145
|
+
|
|
146
|
+
ds_graph = prune_and_merge(final, is_ds_node)
|
|
147
|
+
injected = False
|
|
148
|
+
for datasource in ds_graph.nodes:
|
|
149
|
+
node1 = G.datasources[datasource]
|
|
150
|
+
neighbors = nx.all_neighbors(ds_graph, datasource)
|
|
151
|
+
for neighbor in neighbors:
|
|
152
|
+
node2 = G.datasources[neighbor]
|
|
153
|
+
common_concepts = set(
|
|
154
|
+
x.concept.address for x in node1.columns
|
|
155
|
+
).intersection(set(x.concept.address for x in node2.columns))
|
|
156
|
+
concrete_concepts = [
|
|
157
|
+
x.concept for x in node1.columns if x.concept.address in common_concepts
|
|
158
|
+
]
|
|
159
|
+
reduced = BuildGrain.from_concepts(concrete_concepts).components
|
|
160
|
+
existing_addresses = set()
|
|
161
|
+
for concrete in concrete_concepts:
|
|
162
|
+
logger.info(
|
|
163
|
+
f"looking at column {concrete.address} with pseudonyms {concrete.pseudonyms}"
|
|
164
|
+
)
|
|
165
|
+
cnode = concept_to_node(concrete.with_default_grain())
|
|
166
|
+
if cnode in final.nodes:
|
|
167
|
+
existing_addresses.add(concrete.address)
|
|
168
|
+
continue
|
|
169
|
+
for concrete in concrete_concepts:
|
|
170
|
+
if concrete.address in synonyms:
|
|
171
|
+
continue
|
|
172
|
+
if concrete.address not in reduced:
|
|
173
|
+
continue
|
|
174
|
+
# skip anything that is already in the graph pseudonyms
|
|
175
|
+
if any(x in concrete.pseudonyms for x in existing_addresses):
|
|
176
|
+
continue
|
|
177
|
+
cnode = concept_to_node(concrete.with_default_grain())
|
|
178
|
+
final.add_edge(datasource, cnode)
|
|
179
|
+
final.add_edge(neighbor, cnode)
|
|
180
|
+
logger.info(
|
|
181
|
+
f"{LOGGER_PREFIX} reinjecting common join key {cnode} between {datasource} and {neighbor}"
|
|
182
|
+
)
|
|
183
|
+
injected = True
|
|
184
|
+
return injected
|
|
185
|
+
|
|
186
|
+
|
|
87
187
|
def determine_induced_minimal_nodes(
|
|
88
188
|
G: ReferenceGraph,
|
|
89
189
|
nodelist: list[str],
|
|
90
190
|
environment: BuildEnvironment,
|
|
91
191
|
filter_downstream: bool,
|
|
92
192
|
accept_partial: bool = False,
|
|
193
|
+
synonyms: set[str] = set(),
|
|
93
194
|
) -> nx.DiGraph | None:
|
|
94
195
|
H: nx.Graph = nx.to_undirected(G).copy()
|
|
95
196
|
nodes_to_remove = []
|
|
@@ -129,7 +230,7 @@ def determine_induced_minimal_nodes(
|
|
|
129
230
|
return None
|
|
130
231
|
path_removals = list(x for x in H.nodes if x not in paths)
|
|
131
232
|
if path_removals:
|
|
132
|
-
logger.debug(f"Removing paths {path_removals} from graph")
|
|
233
|
+
# logger.debug(f"Removing paths {path_removals} from graph")
|
|
133
234
|
H.remove_nodes_from(path_removals)
|
|
134
235
|
# logger.debug(f"Graph after path removal {H.nodes}")
|
|
135
236
|
sG: nx.Graph = ax.steinertree.steiner_tree(H, nodelist).copy()
|
|
@@ -148,8 +249,10 @@ def determine_induced_minimal_nodes(
|
|
|
148
249
|
if not accept_partial:
|
|
149
250
|
continue
|
|
150
251
|
final.add_edge(*edge)
|
|
151
|
-
# all concept nodes must have a parent
|
|
152
252
|
|
|
253
|
+
reinject_common_join_keys_v2(G, final, nodelist, synonyms)
|
|
254
|
+
|
|
255
|
+
# all concept nodes must have a parent
|
|
153
256
|
if not all(
|
|
154
257
|
[
|
|
155
258
|
final.in_degree(node) > 0
|
|
@@ -302,6 +405,7 @@ def resolve_weak_components(
|
|
|
302
405
|
filter_downstream=filter_downstream,
|
|
303
406
|
accept_partial=accept_partial,
|
|
304
407
|
environment=environment,
|
|
408
|
+
synonyms=synonyms,
|
|
305
409
|
)
|
|
306
410
|
|
|
307
411
|
if not g or not g.nodes:
|
|
@@ -26,6 +26,15 @@ def validate_key_concept(
|
|
|
26
26
|
):
|
|
27
27
|
results: list[ValidationTest] = []
|
|
28
28
|
seen: dict[str, int] = {}
|
|
29
|
+
|
|
30
|
+
count = 0
|
|
31
|
+
for datasource in build_env.datasources.values():
|
|
32
|
+
if concept.address in [c.address for c in datasource.concepts]:
|
|
33
|
+
count += 1
|
|
34
|
+
# if it only has one source, it's a key
|
|
35
|
+
if count <= 1:
|
|
36
|
+
return results
|
|
37
|
+
|
|
29
38
|
for datasource in build_env.datasources.values():
|
|
30
39
|
if concept.address in [c.address for c in datasource.concepts]:
|
|
31
40
|
assignment = [
|
trilogy/dialect/common.py
CHANGED
|
@@ -10,7 +10,6 @@ from trilogy.core.models.build import (
|
|
|
10
10
|
BuildParamaterizedConceptReference,
|
|
11
11
|
BuildParenthetical,
|
|
12
12
|
)
|
|
13
|
-
from trilogy.core.models.datasource import RawColumnExpr
|
|
14
13
|
from trilogy.core.models.execute import (
|
|
15
14
|
CTE,
|
|
16
15
|
InstantiatedUnnestJoin,
|
|
@@ -65,15 +64,8 @@ def render_join_concept(
|
|
|
65
64
|
inlined_ctes: set[str],
|
|
66
65
|
):
|
|
67
66
|
if cte.name in inlined_ctes:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if isinstance(raw_content, RawColumnExpr):
|
|
71
|
-
rval = raw_content.text
|
|
72
|
-
return rval
|
|
73
|
-
elif isinstance(raw_content, BuildFunction):
|
|
74
|
-
rval = render_expr(raw_content, cte=cte)
|
|
75
|
-
return rval
|
|
76
|
-
return f"{quote_character}{name}{quote_character}.{quote_character}{raw_content}{quote_character}"
|
|
67
|
+
base = render_expr(concept, cte)
|
|
68
|
+
return base
|
|
77
69
|
return f"{quote_character}{name}{quote_character}.{quote_character}{concept.safe_address}{quote_character}"
|
|
78
70
|
|
|
79
71
|
|
trilogy/dialect/metadata.py
CHANGED
|
@@ -174,7 +174,7 @@ def raw_validation_to_result(
|
|
|
174
174
|
) -> Optional[MockResult]:
|
|
175
175
|
"""Convert raw validation tests to mock result."""
|
|
176
176
|
if not raw:
|
|
177
|
-
return
|
|
177
|
+
return MockResult([], ["check_type", "expected", "result", "ran", "query"])
|
|
178
178
|
output = []
|
|
179
179
|
for row in raw:
|
|
180
180
|
if row.raw_query and generator and not row.generated_query:
|
trilogy/executor.py
CHANGED
|
@@ -410,6 +410,13 @@ class Executor(object):
|
|
|
410
410
|
)
|
|
411
411
|
output.extend(results)
|
|
412
412
|
continue
|
|
413
|
+
elif isinstance(statement, ProcessedValidateStatement):
|
|
414
|
+
validate_result = handle_processed_validate_statement(
|
|
415
|
+
statement, self.generator, self.validate_environment
|
|
416
|
+
)
|
|
417
|
+
if validate_result:
|
|
418
|
+
output.append(validate_result)
|
|
419
|
+
continue
|
|
413
420
|
if non_interactive:
|
|
414
421
|
if not isinstance(
|
|
415
422
|
statement, (ProcessedCopyStatement, ProcessedQueryPersist)
|
trilogy/parsing/parse_engine.py
CHANGED
|
@@ -1002,7 +1002,7 @@ class ParseToObjects(Transformer):
|
|
|
1002
1002
|
def validate_statement(self, meta: Meta, args) -> ValidateStatement:
|
|
1003
1003
|
if len(args) == 2:
|
|
1004
1004
|
scope = args[0]
|
|
1005
|
-
targets = args[1]
|
|
1005
|
+
targets = args[1].split(",")
|
|
1006
1006
|
elif len(args) == 0:
|
|
1007
1007
|
scope = ValidationScope.ALL
|
|
1008
1008
|
targets = None
|
|
@@ -2295,7 +2295,7 @@ def parse_text(
|
|
|
2295
2295
|
raise _create_syntax_error(210, pos, text)
|
|
2296
2296
|
|
|
2297
2297
|
# Handle FROM token error
|
|
2298
|
-
parsed_tokens = [x.value for x in e.token_history] if e.token_history else []
|
|
2298
|
+
parsed_tokens = [x.value for x in e.token_history if x] if e.token_history else []
|
|
2299
2299
|
if parsed_tokens == ["FROM"]:
|
|
2300
2300
|
raise _create_syntax_error(101, pos, text)
|
|
2301
2301
|
|
trilogy/parsing/render.py
CHANGED
|
@@ -546,8 +546,8 @@ class Renderer:
|
|
|
546
546
|
return f"{self.to_string(arg.arguments[0])}[{self.to_string(arg.arguments[1])}]"
|
|
547
547
|
|
|
548
548
|
if arg.operator == FunctionType.CASE:
|
|
549
|
-
inputs = "\n".join(args)
|
|
550
|
-
return f"CASE
|
|
549
|
+
inputs = "\n\t".join(args)
|
|
550
|
+
return f"CASE\n\t{inputs}\nEND"
|
|
551
551
|
return f"{arg.operator.value}({inputs})"
|
|
552
552
|
|
|
553
553
|
@to_string.register
|
trilogy/std/metric.preql
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Length and distance units
|
|
2
|
+
type m numeric; # meters
|
|
3
|
+
type km numeric; # kilometers
|
|
4
|
+
type cm numeric; # centimeters
|
|
5
|
+
type mm numeric; # millimeters
|
|
6
|
+
|
|
7
|
+
# Mass units
|
|
8
|
+
type kg numeric; # kilograms
|
|
9
|
+
type g numeric; # grams
|
|
10
|
+
type tonne numeric; # metric tons (1000 kg)
|
|
11
|
+
|
|
12
|
+
# Force units
|
|
13
|
+
type n numeric; # newtons
|
|
14
|
+
type kn numeric; # kilonewtons (1000 N)
|
|
15
|
+
type mn numeric; # meganewtons (1,000,000 N)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|