pytrilogy 0.0.2.43__py3-none-any.whl → 0.0.2.45__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.2.43.dist-info → pytrilogy-0.0.2.45.dist-info}/METADATA +1 -1
- {pytrilogy-0.0.2.43.dist-info → pytrilogy-0.0.2.45.dist-info}/RECORD +10 -10
- trilogy/__init__.py +1 -1
- trilogy/core/models.py +20 -10
- trilogy/core/processing/node_generators/multiselect_node.py +12 -3
- trilogy/core/processing/node_generators/select_merge_node.py +17 -1
- {pytrilogy-0.0.2.43.dist-info → pytrilogy-0.0.2.45.dist-info}/LICENSE.md +0 -0
- {pytrilogy-0.0.2.43.dist-info → pytrilogy-0.0.2.45.dist-info}/WHEEL +0 -0
- {pytrilogy-0.0.2.43.dist-info → pytrilogy-0.0.2.45.dist-info}/entry_points.txt +0 -0
- {pytrilogy-0.0.2.43.dist-info → pytrilogy-0.0.2.45.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
trilogy/__init__.py,sha256=
|
|
1
|
+
trilogy/__init__.py,sha256=UvZczB4kSHAfRSvHaEiwHBDkkIKuVLZsvZVUni5kMc8,291
|
|
2
2
|
trilogy/compiler.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
trilogy/constants.py,sha256=UPymm94T2c6a55XdDaXw0aleTe1pOJ6lf6gOWLKZyKg,1430
|
|
4
4
|
trilogy/engine.py,sha256=R5ubIxYyrxRExz07aZCUfrTsoXCHQ8DKFTDsobXdWdA,1102
|
|
@@ -16,7 +16,7 @@ trilogy/core/exceptions.py,sha256=1c1lQCwSw4_5CQS3q7scOkXU8GQvullJXfPHubprl90,61
|
|
|
16
16
|
trilogy/core/functions.py,sha256=IhVpt3n6wEanKHnGu3oA2w6-hKIlxWpEyz7fHN66mpo,10720
|
|
17
17
|
trilogy/core/graph_models.py,sha256=mameUTiuCajtihDw_2-W218xyJlvTusOWrEKP1yAWgk,2003
|
|
18
18
|
trilogy/core/internal.py,sha256=jNGFHKENnbMiMCtAgsnLZYVSENDK4b5ALecXFZpTDzQ,1075
|
|
19
|
-
trilogy/core/models.py,sha256=
|
|
19
|
+
trilogy/core/models.py,sha256=WxmOgW0cTUgcBVu_gLPUwA9j3KWYPH5FsxKzBSJukEg,164085
|
|
20
20
|
trilogy/core/optimization.py,sha256=VFSvJLNoCCOraip-PZUKeE4qrlxtXARjQUzJZiW-yRk,7325
|
|
21
21
|
trilogy/core/query_processor.py,sha256=mbcZlgjChrRjDHkdmMbKe-T70UpbBkJhS09MyU5a6UY,17785
|
|
22
22
|
trilogy/core/optimizations/__init__.py,sha256=bWQecbeiwiDx9LJnLsa7dkWxdbl2wcnkcTN69JyP8iI,356
|
|
@@ -34,10 +34,10 @@ trilogy/core/processing/node_generators/common.py,sha256=eslHTTPFTkmwHwKIuUsbFn5
|
|
|
34
34
|
trilogy/core/processing/node_generators/filter_node.py,sha256=Vz9Rb67e1dfZgnliekwwLeDPVkthMbdrnrKRdz7J1ik,7654
|
|
35
35
|
trilogy/core/processing/node_generators/group_node.py,sha256=r54IVEhXW-tzod6uEHIQObrxgQt6aNySk5emWkWyqCU,4938
|
|
36
36
|
trilogy/core/processing/node_generators/group_to_node.py,sha256=R9i_wHipxjXJyfYEwfeTw2EPpuanXVA327XyfcP2tBg,2537
|
|
37
|
-
trilogy/core/processing/node_generators/multiselect_node.py,sha256=
|
|
37
|
+
trilogy/core/processing/node_generators/multiselect_node.py,sha256=Prn0tWu6gpxyP1tJywVoMG6YAKB8kVRRpPMYdqnl6SE,6583
|
|
38
38
|
trilogy/core/processing/node_generators/node_merge_node.py,sha256=dIEv5P2MTViAES2MzqJgccYzM3HldjHrQYFwH00cqyc,14003
|
|
39
39
|
trilogy/core/processing/node_generators/rowset_node.py,sha256=KtdN6t2xM8CJxobc4aQX4W8uX98U6IabeuBF_FtBLR4,4583
|
|
40
|
-
trilogy/core/processing/node_generators/select_merge_node.py,sha256=
|
|
40
|
+
trilogy/core/processing/node_generators/select_merge_node.py,sha256=zVPSYzhl-jSMobL7L1JauG03yNMkhKp0-tOVXiuC0Vo,12690
|
|
41
41
|
trilogy/core/processing/node_generators/select_node.py,sha256=xTCWOoucRPBWkTccm5wepidhuZix-wd0YXWyOsy8nLs,1795
|
|
42
42
|
trilogy/core/processing/node_generators/unnest_node.py,sha256=cZ26CN338CBnd6asML1OBUtNcDzmNlFpY0Vnade4yrc,2256
|
|
43
43
|
trilogy/core/processing/node_generators/window_node.py,sha256=Ywb2K0T5Ym_Y4XStzIE2fuWV1fW2dp5eQ2hXVFTLsGM,3511
|
|
@@ -75,9 +75,9 @@ trilogy/parsing/render.py,sha256=-qqpXQg4yHcv284Vosjnsc_vrPveH6oaYbeCd3ZSvs0,156
|
|
|
75
75
|
trilogy/parsing/trilogy.lark,sha256=B6NM3-rBHtYB_WSEti0DiS8Z-I8YH3kZU47xNzQvBx4,12389
|
|
76
76
|
trilogy/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
77
77
|
trilogy/scripts/trilogy.py,sha256=PHxvv6f2ODv0esyyhWxlARgra8dVhqQhYl0lTrSyVNo,3729
|
|
78
|
-
pytrilogy-0.0.2.
|
|
79
|
-
pytrilogy-0.0.2.
|
|
80
|
-
pytrilogy-0.0.2.
|
|
81
|
-
pytrilogy-0.0.2.
|
|
82
|
-
pytrilogy-0.0.2.
|
|
83
|
-
pytrilogy-0.0.2.
|
|
78
|
+
pytrilogy-0.0.2.45.dist-info/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
|
|
79
|
+
pytrilogy-0.0.2.45.dist-info/METADATA,sha256=3yU7J0Qxk2FqzC6WKBP-AL8JOp_loHi_x6_gZwlF-DM,8426
|
|
80
|
+
pytrilogy-0.0.2.45.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
81
|
+
pytrilogy-0.0.2.45.dist-info/entry_points.txt,sha256=0petKryjvvtEfTlbZC1AuMFumH_WQ9v8A19LvoS6G6c,54
|
|
82
|
+
pytrilogy-0.0.2.45.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
|
|
83
|
+
pytrilogy-0.0.2.45.dist-info/RECORD,,
|
trilogy/__init__.py
CHANGED
trilogy/core/models.py
CHANGED
|
@@ -2307,9 +2307,11 @@ class UnnestJoin(BaseModel):
|
|
|
2307
2307
|
rendering_required: bool = True
|
|
2308
2308
|
|
|
2309
2309
|
def __hash__(self):
|
|
2310
|
-
return (
|
|
2311
|
-
|
|
2312
|
-
|
|
2310
|
+
return self.safe_identifier.__hash__()
|
|
2311
|
+
|
|
2312
|
+
@property
|
|
2313
|
+
def safe_identifier(self) -> str:
|
|
2314
|
+
return self.alias + "".join([str(s.address) for s in self.concepts])
|
|
2313
2315
|
|
|
2314
2316
|
|
|
2315
2317
|
class InstantiatedUnnestJoin(BaseModel):
|
|
@@ -2544,7 +2546,7 @@ class QueryDatasource(BaseModel):
|
|
|
2544
2546
|
return True
|
|
2545
2547
|
return False
|
|
2546
2548
|
|
|
2547
|
-
def __add__(self, other):
|
|
2549
|
+
def __add__(self, other) -> "QueryDatasource":
|
|
2548
2550
|
# these are syntax errors to avoid being caught by current
|
|
2549
2551
|
if not isinstance(other, QueryDatasource):
|
|
2550
2552
|
raise SyntaxError("Can only merge two query datasources")
|
|
@@ -2570,7 +2572,7 @@ class QueryDatasource(BaseModel):
|
|
|
2570
2572
|
f" {other.name} with {[c.address for c in other.output_concepts]} concepts"
|
|
2571
2573
|
)
|
|
2572
2574
|
|
|
2573
|
-
merged_datasources = {}
|
|
2575
|
+
merged_datasources: dict[str, Union[Datasource, "QueryDatasource"]] = {}
|
|
2574
2576
|
|
|
2575
2577
|
for ds in [*self.datasources, *other.datasources]:
|
|
2576
2578
|
if ds.safe_identifier in merged_datasources:
|
|
@@ -2580,20 +2582,29 @@ class QueryDatasource(BaseModel):
|
|
|
2580
2582
|
else:
|
|
2581
2583
|
merged_datasources[ds.safe_identifier] = ds
|
|
2582
2584
|
|
|
2583
|
-
final_source_map
|
|
2585
|
+
final_source_map: defaultdict[
|
|
2586
|
+
str, Set[Union[Datasource, "QueryDatasource", "UnnestJoin"]]
|
|
2587
|
+
] = defaultdict(set)
|
|
2588
|
+
|
|
2589
|
+
# add our sources
|
|
2584
2590
|
for key in self.source_map:
|
|
2585
2591
|
final_source_map[key] = self.source_map[key].union(
|
|
2586
2592
|
other.source_map.get(key, set())
|
|
2587
2593
|
)
|
|
2594
|
+
# add their sources
|
|
2588
2595
|
for key in other.source_map:
|
|
2589
2596
|
if key not in final_source_map:
|
|
2590
2597
|
final_source_map[key] = other.source_map[key]
|
|
2598
|
+
|
|
2599
|
+
# if a ds was merged (to combine columns), we need to update the source map
|
|
2600
|
+
# to use the merged item
|
|
2591
2601
|
for k, v in final_source_map.items():
|
|
2592
2602
|
final_source_map[k] = set(
|
|
2593
|
-
merged_datasources
|
|
2603
|
+
merged_datasources.get(x.safe_identifier, x) for x in list(v)
|
|
2594
2604
|
)
|
|
2595
2605
|
self_hidden = self.hidden_concepts or []
|
|
2596
2606
|
other_hidden = other.hidden_concepts or []
|
|
2607
|
+
# hidden is the minimum overlapping set
|
|
2597
2608
|
hidden = [x for x in self_hidden if x.address in other_hidden]
|
|
2598
2609
|
qds = QueryDatasource(
|
|
2599
2610
|
input_concepts=unique(
|
|
@@ -2606,11 +2617,10 @@ class QueryDatasource(BaseModel):
|
|
|
2606
2617
|
datasources=list(merged_datasources.values()),
|
|
2607
2618
|
grain=self.grain,
|
|
2608
2619
|
joins=unique(self.joins + other.joins, "unique_id"),
|
|
2609
|
-
# joins = self.joins,
|
|
2610
2620
|
condition=(
|
|
2611
2621
|
self.condition + other.condition
|
|
2612
|
-
if
|
|
2613
|
-
else
|
|
2622
|
+
if self.condition and other.condition
|
|
2623
|
+
else self.condition or other.condition
|
|
2614
2624
|
),
|
|
2615
2625
|
source_type=self.source_type,
|
|
2616
2626
|
partial_concepts=unique(
|
|
@@ -3,6 +3,7 @@ from trilogy.core.models import (
|
|
|
3
3
|
Environment,
|
|
4
4
|
MultiSelectStatement,
|
|
5
5
|
WhereClause,
|
|
6
|
+
Conditional,
|
|
6
7
|
)
|
|
7
8
|
from trilogy.core.processing.nodes import MergeNode, NodeJoin, History
|
|
8
9
|
from trilogy.core.processing.nodes.base_node import concept_list_to_grain, StrategyNode
|
|
@@ -14,7 +15,7 @@ from trilogy.core.processing.utility import padding
|
|
|
14
15
|
from trilogy.core.processing.utility import concept_to_relevant_joins
|
|
15
16
|
from collections import defaultdict
|
|
16
17
|
from itertools import combinations
|
|
17
|
-
from trilogy.core.enums import Purpose
|
|
18
|
+
from trilogy.core.enums import Purpose, BooleanOperator
|
|
18
19
|
from trilogy.core.processing.node_generators.common import resolve_join_order
|
|
19
20
|
|
|
20
21
|
LOGGER_PREFIX = "[GEN_MULTISELECT_NODE]"
|
|
@@ -76,14 +77,22 @@ def gen_multiselect_node(
|
|
|
76
77
|
g=g,
|
|
77
78
|
depth=depth + 1,
|
|
78
79
|
history=history,
|
|
80
|
+
conditions=select.where_clause,
|
|
79
81
|
)
|
|
80
82
|
if not snode:
|
|
81
83
|
logger.info(
|
|
82
84
|
f"{padding(depth)}{LOGGER_PREFIX} Cannot generate multiselect node for {concept}"
|
|
83
85
|
)
|
|
84
86
|
return None
|
|
85
|
-
if select.
|
|
86
|
-
snode.conditions
|
|
87
|
+
if select.having_clause:
|
|
88
|
+
if snode.conditions:
|
|
89
|
+
snode.conditions = Conditional(
|
|
90
|
+
left=snode.conditions,
|
|
91
|
+
right=select.having_clause.conditional,
|
|
92
|
+
operator=BooleanOperator.AND,
|
|
93
|
+
)
|
|
94
|
+
else:
|
|
95
|
+
snode.conditions = select.having_clause.conditional
|
|
87
96
|
merge_concepts = []
|
|
88
97
|
for x in [*snode.output_concepts]:
|
|
89
98
|
merge = lineage.get_merge_concept(x)
|
|
@@ -20,6 +20,9 @@ from trilogy.core.graph_models import concept_to_node
|
|
|
20
20
|
from trilogy.constants import logger
|
|
21
21
|
from trilogy.core.processing.utility import padding
|
|
22
22
|
from trilogy.core.enums import PurposeLineage
|
|
23
|
+
from trilogy.core.processing.nodes.base_node import (
|
|
24
|
+
concept_list_to_grain,
|
|
25
|
+
)
|
|
23
26
|
|
|
24
27
|
LOGGER_PREFIX = "[GEN_ROOT_MERGE_NODE]"
|
|
25
28
|
|
|
@@ -353,7 +356,7 @@ def gen_select_merge_node(
|
|
|
353
356
|
]
|
|
354
357
|
):
|
|
355
358
|
preexisting_conditions = conditions.conditional
|
|
356
|
-
|
|
359
|
+
base = MergeNode(
|
|
357
360
|
output_concepts=all_concepts,
|
|
358
361
|
input_concepts=non_constant,
|
|
359
362
|
environment=environment,
|
|
@@ -362,3 +365,16 @@ def gen_select_merge_node(
|
|
|
362
365
|
parents=parents,
|
|
363
366
|
preexisting_conditions=preexisting_conditions,
|
|
364
367
|
)
|
|
368
|
+
target_grain = concept_list_to_grain(all_concepts, [])
|
|
369
|
+
if not base.resolve().grain.issubset(target_grain):
|
|
370
|
+
return GroupNode(
|
|
371
|
+
output_concepts=all_concepts,
|
|
372
|
+
input_concepts=all_concepts,
|
|
373
|
+
environment=environment,
|
|
374
|
+
g=g,
|
|
375
|
+
parents=[base],
|
|
376
|
+
depth=depth,
|
|
377
|
+
preexisting_conditions=preexisting_conditions,
|
|
378
|
+
partial_concepts=base.partial_concepts,
|
|
379
|
+
)
|
|
380
|
+
return base
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|