pytrilogy 0.0.2.57__py3-none-any.whl → 0.0.2.58__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.57.dist-info → pytrilogy-0.0.2.58.dist-info}/METADATA +1 -1
- {pytrilogy-0.0.2.57.dist-info → pytrilogy-0.0.2.58.dist-info}/RECORD +21 -21
- trilogy/__init__.py +1 -1
- trilogy/core/models.py +16 -16
- trilogy/core/optimization.py +3 -6
- trilogy/core/processing/concept_strategies_v3.py +1 -1
- trilogy/core/processing/node_generators/common.py +1 -1
- trilogy/core/processing/node_generators/group_to_node.py +2 -2
- trilogy/core/processing/node_generators/multiselect_node.py +1 -1
- trilogy/core/processing/node_generators/rowset_node.py +4 -2
- trilogy/core/processing/nodes/base_node.py +10 -11
- trilogy/core/processing/nodes/group_node.py +5 -5
- trilogy/core/processing/nodes/merge_node.py +2 -2
- trilogy/core/processing/nodes/select_node_v2.py +1 -1
- trilogy/core/processing/utility.py +5 -5
- trilogy/core/query_processor.py +2 -2
- trilogy/dialect/base.py +6 -5
- {pytrilogy-0.0.2.57.dist-info → pytrilogy-0.0.2.58.dist-info}/LICENSE.md +0 -0
- {pytrilogy-0.0.2.57.dist-info → pytrilogy-0.0.2.58.dist-info}/WHEEL +0 -0
- {pytrilogy-0.0.2.57.dist-info → pytrilogy-0.0.2.58.dist-info}/entry_points.txt +0 -0
- {pytrilogy-0.0.2.57.dist-info → pytrilogy-0.0.2.58.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
trilogy/__init__.py,sha256=
|
|
1
|
+
trilogy/__init__.py,sha256=CTKkLw46Arh2GYkTbonpNlj9mv7xV7TLDpB2rTn_afU,291
|
|
2
2
|
trilogy/compiler.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
trilogy/constants.py,sha256=qZ1d0hoKPPV2HHCoFwPYTVB7b6bXjpWvXd3lE-zEhy8,1494
|
|
4
4
|
trilogy/engine.py,sha256=yOPnR7XCjWG82Gym_LLZBkYKKJdLCvqdCyt8zguNcnM,1103
|
|
@@ -16,27 +16,27 @@ trilogy/core/exceptions.py,sha256=1c1lQCwSw4_5CQS3q7scOkXU8GQvullJXfPHubprl90,61
|
|
|
16
16
|
trilogy/core/functions.py,sha256=8auZhInqnY28zg7Kil4LbvDT7jD4JggwS6HzK6ZIemE,10867
|
|
17
17
|
trilogy/core/graph_models.py,sha256=mameUTiuCajtihDw_2-W218xyJlvTusOWrEKP1yAWgk,2003
|
|
18
18
|
trilogy/core/internal.py,sha256=FQWbuETKPfzjALMmdXJwlOMlESfm2Z5gmErSsq3BX9c,1173
|
|
19
|
-
trilogy/core/models.py,sha256=
|
|
20
|
-
trilogy/core/optimization.py,sha256=
|
|
21
|
-
trilogy/core/query_processor.py,sha256
|
|
19
|
+
trilogy/core/models.py,sha256=VrbgVuyKPtMwt3wpQnFFYFpzqNX3B94rlw6PxvpazNQ,165392
|
|
20
|
+
trilogy/core/optimization.py,sha256=dIgpcletzEtcX0hAq74Y4cleAWkznR422geo00rZFKk,7900
|
|
21
|
+
trilogy/core/query_processor.py,sha256=-KjOKsRhvpdR_NKxoyLq83T97Aw3J-4De-hpslzhKfQ,18576
|
|
22
22
|
trilogy/core/optimizations/__init__.py,sha256=EBanqTXEzf1ZEYjAneIWoIcxtMDite5-n2dQ5xcfUtg,356
|
|
23
23
|
trilogy/core/optimizations/base_optimization.py,sha256=P4kF-eCXkBxO-5c6tLHhMZ4ODRH1A04hb_6ovkaVyLw,505
|
|
24
24
|
trilogy/core/optimizations/inline_constant.py,sha256=c-YHOg6eAufL4EaCf4-0PbY_D4skBHW0ldR55_phsMA,1277
|
|
25
25
|
trilogy/core/optimizations/inline_datasource.py,sha256=LsngRKBy-LYcx1sfo1-rnDym_ly73YV9WkEngSjpFx8,3943
|
|
26
26
|
trilogy/core/optimizations/predicate_pushdown.py,sha256=XPWEBv8jXnc0OL2JDPNwFvJ5AtOE7dLzJK0LzdmdZMo,9252
|
|
27
27
|
trilogy/core/processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
-
trilogy/core/processing/concept_strategies_v3.py,sha256=
|
|
28
|
+
trilogy/core/processing/concept_strategies_v3.py,sha256=Ty8JfK0KSCW-RBvw4v7RERe7xuSbzJlRSaqRfcSfOBE,37691
|
|
29
29
|
trilogy/core/processing/graph_utils.py,sha256=stbYnDxnK-1kbo9L4XNU85FQhWCP-oZYO7LCXhAdC5M,1198
|
|
30
|
-
trilogy/core/processing/utility.py,sha256=
|
|
30
|
+
trilogy/core/processing/utility.py,sha256=N2RUGtUuktvy1VXoVpve8F2QtCBEFQf6RWpr0PXXhwk,19671
|
|
31
31
|
trilogy/core/processing/node_generators/__init__.py,sha256=s_YV1OYc336DuS9591259qjI_K_CtOCuhkf4t2aOgYs,733
|
|
32
32
|
trilogy/core/processing/node_generators/basic_node.py,sha256=pExVmLDQK9okXNeC1-jQgDwpj8JWAgQfejd2lMt8L4U,3157
|
|
33
|
-
trilogy/core/processing/node_generators/common.py,sha256=
|
|
33
|
+
trilogy/core/processing/node_generators/common.py,sha256=Ft5giLHFn0t_A_4FPl6MJWsi0ghEen0bPFAmrdZ3S58,9107
|
|
34
34
|
trilogy/core/processing/node_generators/filter_node.py,sha256=aWR82yAZOAnUrJejTj6yD4jpqH6cSPzyJMd1V-M0Kj0,7883
|
|
35
35
|
trilogy/core/processing/node_generators/group_node.py,sha256=k57SVWHSVvTqCd47tyLUGCsSZaP7UQqMCJYTSz1S7oQ,5566
|
|
36
|
-
trilogy/core/processing/node_generators/group_to_node.py,sha256=
|
|
37
|
-
trilogy/core/processing/node_generators/multiselect_node.py,sha256=
|
|
36
|
+
trilogy/core/processing/node_generators/group_to_node.py,sha256=CZiPnD4rEkMOdyBQrDaH6HA3VSMKJ775BiJdQkM7dO8,2939
|
|
37
|
+
trilogy/core/processing/node_generators/multiselect_node.py,sha256=qmaufoSVwavNBNsdw0NGpNOTNWFPDKunA9COohEYW08,6469
|
|
38
38
|
trilogy/core/processing/node_generators/node_merge_node.py,sha256=3GzuiTiorFVe9MyLhoz2PDyI0x9XL7bQ8ucEbV54le8,14627
|
|
39
|
-
trilogy/core/processing/node_generators/rowset_node.py,sha256=
|
|
39
|
+
trilogy/core/processing/node_generators/rowset_node.py,sha256=FDCJORLEcmpF9a071IFl-VbmKjq32rFOXi1SarjBVxY,5167
|
|
40
40
|
trilogy/core/processing/node_generators/select_merge_node.py,sha256=yfNeuc24Ejn7j07szwJif60qmU6OVk3wfa7C2_RJ39k,15996
|
|
41
41
|
trilogy/core/processing/node_generators/select_node.py,sha256=bjTylBa-vYbmzpuSpphmIo_Oi78YZpI8ppHnN9KDYDk,1795
|
|
42
42
|
trilogy/core/processing/node_generators/union_node.py,sha256=MfJjF2m0ARl0oUH9QT1awzPv0e3yA3mXK1XqAvUTgKw,2504
|
|
@@ -45,16 +45,16 @@ trilogy/core/processing/node_generators/window_node.py,sha256=5htRRxaxw6EnS-2TVo
|
|
|
45
45
|
trilogy/core/processing/node_generators/select_helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
46
|
trilogy/core/processing/node_generators/select_helpers/datasource_injection.py,sha256=hJZS7GT0dl7sK0riweEwVAVRv5LCXOnMD1hF0XY9hpE,6548
|
|
47
47
|
trilogy/core/processing/nodes/__init__.py,sha256=WNUmYmZF3uqF2qiJ1L7y0u9qiVD9YnluKds0wA5opJE,4813
|
|
48
|
-
trilogy/core/processing/nodes/base_node.py,sha256=
|
|
48
|
+
trilogy/core/processing/nodes/base_node.py,sha256=YgZaiAlzvwa7AkHXNfMo5R0DJKWdvbDvMWEvTJR7fpM,16081
|
|
49
49
|
trilogy/core/processing/nodes/filter_node.py,sha256=j7icDAXJ7oFPkHTOQVmm9QbZxrhhYEUGJj2lSiguXKA,2292
|
|
50
|
-
trilogy/core/processing/nodes/group_node.py,sha256
|
|
51
|
-
trilogy/core/processing/nodes/merge_node.py,sha256=
|
|
52
|
-
trilogy/core/processing/nodes/select_node_v2.py,sha256=
|
|
50
|
+
trilogy/core/processing/nodes/group_node.py,sha256=7lX9SvOK_-oPeg4UydjYMcp4BB7IneJxT-bqEs-OSQ8,7272
|
|
51
|
+
trilogy/core/processing/nodes/merge_node.py,sha256=lHRL1CpiFUocqyMVzGt97VAH_aUeHAEjebGFL1YwHys,14754
|
|
52
|
+
trilogy/core/processing/nodes/select_node_v2.py,sha256=cwbVuiu81EsX86cHCmiZSydTNJ1V3ODuXQaWO1HU4xQ,8207
|
|
53
53
|
trilogy/core/processing/nodes/union_node.py,sha256=1QgOWkjJ-ADFdanoRzi0EM5buhuzJbmlda9BAUGp4mM,1352
|
|
54
54
|
trilogy/core/processing/nodes/unnest_node.py,sha256=0TFANwqVPaVpUR6SF5uweGTlXfEnagXRBBZU6dUwtcY,2101
|
|
55
55
|
trilogy/core/processing/nodes/window_node.py,sha256=yYwWuOq1Uwm-xEl8lFH_urm-YXaAGAgNhE20MEoD5QQ,1163
|
|
56
56
|
trilogy/dialect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
|
-
trilogy/dialect/base.py,sha256=
|
|
57
|
+
trilogy/dialect/base.py,sha256=TtQ3ATAaXKVsrhMA9EGkSS-vIC_jX0nHCzK5GBrgvrg,38511
|
|
58
58
|
trilogy/dialect/bigquery.py,sha256=mKC3zoEU232h9RtIXJjqiZ72lWH8a6S28p6wAZKrAfg,2952
|
|
59
59
|
trilogy/dialect/common.py,sha256=b0E6JqdKaaSzThLiFa9jwUg4YnXahf-3bqmzOn5z-6E,3827
|
|
60
60
|
trilogy/dialect/config.py,sha256=UiBY2tBbNk9owx-zxP_3lN9lErEUXhXIU_bcXA18AvU,2992
|
|
@@ -79,9 +79,9 @@ trilogy/parsing/render.py,sha256=o4C12a407iZvlRGUJDiuJUezrLLo4QEaLtu60ZQX3gk,169
|
|
|
79
79
|
trilogy/parsing/trilogy.lark,sha256=EazfEvYPuvkPkNjUnVzFi0uD9baavugbSI8CyfawShk,12573
|
|
80
80
|
trilogy/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
81
81
|
trilogy/scripts/trilogy.py,sha256=DQDW81E5mDMWFP8oPw8q-IyrR2JGxQSDWgUWe2VTSRQ,3731
|
|
82
|
-
pytrilogy-0.0.2.
|
|
83
|
-
pytrilogy-0.0.2.
|
|
84
|
-
pytrilogy-0.0.2.
|
|
85
|
-
pytrilogy-0.0.2.
|
|
86
|
-
pytrilogy-0.0.2.
|
|
87
|
-
pytrilogy-0.0.2.
|
|
82
|
+
pytrilogy-0.0.2.58.dist-info/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
|
|
83
|
+
pytrilogy-0.0.2.58.dist-info/METADATA,sha256=PYvDIfNL0E2TRIBxawpJ_SyhNDfc2TWlFnL5uOeGO0E,8823
|
|
84
|
+
pytrilogy-0.0.2.58.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
85
|
+
pytrilogy-0.0.2.58.dist-info/entry_points.txt,sha256=0petKryjvvtEfTlbZC1AuMFumH_WQ9v8A19LvoS6G6c,54
|
|
86
|
+
pytrilogy-0.0.2.58.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
|
|
87
|
+
pytrilogy-0.0.2.58.dist-info/RECORD,,
|
trilogy/__init__.py
CHANGED
trilogy/core/models.py
CHANGED
|
@@ -1870,11 +1870,11 @@ class SelectStatement(HasUUID, Mergeable, Namespaced, SelectTypeMixin, BaseModel
|
|
|
1870
1870
|
return output
|
|
1871
1871
|
|
|
1872
1872
|
@property
|
|
1873
|
-
def hidden_components(self) ->
|
|
1874
|
-
output =
|
|
1873
|
+
def hidden_components(self) -> set[str]:
|
|
1874
|
+
output = set()
|
|
1875
1875
|
for item in self.selection:
|
|
1876
1876
|
if isinstance(item, SelectItem) and Modifier.HIDDEN in item.modifiers:
|
|
1877
|
-
output.
|
|
1877
|
+
output.add(item.output.address)
|
|
1878
1878
|
return output
|
|
1879
1879
|
|
|
1880
1880
|
@property
|
|
@@ -2104,10 +2104,10 @@ class MultiSelectStatement(HasUUID, SelectTypeMixin, Mergeable, Namespaced, Base
|
|
|
2104
2104
|
|
|
2105
2105
|
@computed_field # type: ignore
|
|
2106
2106
|
@cached_property
|
|
2107
|
-
def hidden_components(self) ->
|
|
2108
|
-
output =
|
|
2107
|
+
def hidden_components(self) -> set[str]:
|
|
2108
|
+
output: set[str] = set()
|
|
2109
2109
|
for select in self.selects:
|
|
2110
|
-
output
|
|
2110
|
+
output = output.union(select.hidden_components)
|
|
2111
2111
|
return output
|
|
2112
2112
|
|
|
2113
2113
|
|
|
@@ -2508,7 +2508,7 @@ class QueryDatasource(BaseModel):
|
|
|
2508
2508
|
filter_concepts: List[Concept] = Field(default_factory=list)
|
|
2509
2509
|
source_type: SourceType = SourceType.SELECT
|
|
2510
2510
|
partial_concepts: List[Concept] = Field(default_factory=list)
|
|
2511
|
-
hidden_concepts:
|
|
2511
|
+
hidden_concepts: set[str] = Field(default_factory=set)
|
|
2512
2512
|
nullable_concepts: List[Concept] = Field(default_factory=list)
|
|
2513
2513
|
join_derived_concepts: List[Concept] = Field(default_factory=list)
|
|
2514
2514
|
force_group: bool | None = None
|
|
@@ -2660,10 +2660,10 @@ class QueryDatasource(BaseModel):
|
|
|
2660
2660
|
final_source_map[k] = set(
|
|
2661
2661
|
merged_datasources.get(x.safe_identifier, x) for x in list(v)
|
|
2662
2662
|
)
|
|
2663
|
-
self_hidden = self.hidden_concepts or
|
|
2664
|
-
other_hidden = other.hidden_concepts or
|
|
2663
|
+
self_hidden: set[str] = self.hidden_concepts or set()
|
|
2664
|
+
other_hidden: set[str] = other.hidden_concepts or set()
|
|
2665
2665
|
# hidden is the minimum overlapping set
|
|
2666
|
-
hidden =
|
|
2666
|
+
hidden = self_hidden.intersection(other_hidden)
|
|
2667
2667
|
qds = QueryDatasource(
|
|
2668
2668
|
input_concepts=unique(
|
|
2669
2669
|
self.input_concepts + other.input_concepts, "address"
|
|
@@ -2761,7 +2761,7 @@ class CTE(BaseModel):
|
|
|
2761
2761
|
partial_concepts: List[Concept] = Field(default_factory=list)
|
|
2762
2762
|
nullable_concepts: List[Concept] = Field(default_factory=list)
|
|
2763
2763
|
join_derived_concepts: List[Concept] = Field(default_factory=list)
|
|
2764
|
-
hidden_concepts:
|
|
2764
|
+
hidden_concepts: set[str] = Field(default_factory=set)
|
|
2765
2765
|
order_by: Optional[OrderBy] = None
|
|
2766
2766
|
limit: Optional[int] = None
|
|
2767
2767
|
base_name_override: Optional[str] = None
|
|
@@ -2947,10 +2947,10 @@ class CTE(BaseModel):
|
|
|
2947
2947
|
f" {self.name} {other.name} conditions {self.condition} {other.condition}"
|
|
2948
2948
|
)
|
|
2949
2949
|
raise ValueError(error)
|
|
2950
|
-
mutually_hidden =
|
|
2950
|
+
mutually_hidden = set()
|
|
2951
2951
|
for concept in self.hidden_concepts:
|
|
2952
|
-
if concept
|
|
2953
|
-
mutually_hidden.
|
|
2952
|
+
if concept in other.hidden_concepts:
|
|
2953
|
+
mutually_hidden.add(concept)
|
|
2954
2954
|
self.partial_concepts = unique(
|
|
2955
2955
|
self.partial_concepts + other.partial_concepts, "address"
|
|
2956
2956
|
)
|
|
@@ -3132,7 +3132,7 @@ class UnionCTE(BaseModel):
|
|
|
3132
3132
|
operator: str = "UNION ALL"
|
|
3133
3133
|
order_by: Optional[OrderBy] = None
|
|
3134
3134
|
limit: Optional[int] = None
|
|
3135
|
-
hidden_concepts:
|
|
3135
|
+
hidden_concepts: set[str] = Field(default_factory=set)
|
|
3136
3136
|
partial_concepts: list[Concept] = Field(default_factory=list)
|
|
3137
3137
|
existence_source_map: Dict[str, list[str]] = Field(default_factory=dict)
|
|
3138
3138
|
|
|
@@ -4504,7 +4504,7 @@ class ProcessedQuery(BaseModel):
|
|
|
4504
4504
|
base: CTE | UnionCTE
|
|
4505
4505
|
joins: List[Join]
|
|
4506
4506
|
grain: Grain
|
|
4507
|
-
hidden_columns:
|
|
4507
|
+
hidden_columns: set[str] = Field(default_factory=set)
|
|
4508
4508
|
limit: Optional[int] = None
|
|
4509
4509
|
where_clause: Optional[WhereClause] = None
|
|
4510
4510
|
having_clause: Optional[HavingClause] = None
|
trilogy/core/optimization.py
CHANGED
|
@@ -136,15 +136,12 @@ def is_direct_return_eligible(cte: CTE | UnionCTE) -> CTE | UnionCTE | None:
|
|
|
136
136
|
|
|
137
137
|
assert isinstance(cte, CTE)
|
|
138
138
|
derived_concepts = [
|
|
139
|
-
c
|
|
140
|
-
for c in cte.source.output_concepts + cte.source.hidden_concepts
|
|
141
|
-
if c not in cte.source.input_concepts
|
|
139
|
+
c for c in cte.source.output_concepts if c not in cte.source.input_concepts
|
|
142
140
|
]
|
|
143
141
|
|
|
144
142
|
parent_derived_concepts = [
|
|
145
143
|
c
|
|
146
144
|
for c in direct_parent.source.output_concepts
|
|
147
|
-
+ direct_parent.source.hidden_concepts
|
|
148
145
|
if c not in direct_parent.source.input_concepts
|
|
149
146
|
]
|
|
150
147
|
condition_arguments = cte.condition.row_arguments if cte.condition else []
|
|
@@ -180,8 +177,8 @@ def optimize_ctes(
|
|
|
180
177
|
):
|
|
181
178
|
direct_parent.order_by = root_cte.order_by
|
|
182
179
|
direct_parent.limit = root_cte.limit
|
|
183
|
-
direct_parent.hidden_concepts = (
|
|
184
|
-
|
|
180
|
+
direct_parent.hidden_concepts = root_cte.hidden_concepts.union(
|
|
181
|
+
direct_parent.hidden_concepts
|
|
185
182
|
)
|
|
186
183
|
if root_cte.condition:
|
|
187
184
|
if direct_parent.condition:
|
|
@@ -208,7 +208,7 @@ def gen_enrichment_node(
|
|
|
208
208
|
non_hidden = [
|
|
209
209
|
x
|
|
210
210
|
for x in base_node.output_concepts
|
|
211
|
-
if x.address not in
|
|
211
|
+
if x.address not in base_node.hidden_concepts
|
|
212
212
|
]
|
|
213
213
|
return MergeNode(
|
|
214
214
|
input_concepts=unique(join_keys + extra_required + non_hidden, "address"),
|
|
@@ -49,8 +49,8 @@ def gen_group_to_node(
|
|
|
49
49
|
parents=parents,
|
|
50
50
|
depth=depth,
|
|
51
51
|
preexisting_conditions=conditions.conditional if conditions else None,
|
|
52
|
-
hidden_concepts=(
|
|
53
|
-
[group_arg]
|
|
52
|
+
hidden_concepts=set(
|
|
53
|
+
[group_arg.address]
|
|
54
54
|
if isinstance(group_arg, Concept)
|
|
55
55
|
and group_arg.address not in local_optional
|
|
56
56
|
else []
|
|
@@ -116,7 +116,7 @@ def gen_multiselect_node(
|
|
|
116
116
|
depth=depth,
|
|
117
117
|
parents=base_parents,
|
|
118
118
|
node_joins=node_joins,
|
|
119
|
-
hidden_concepts=[x for y in base_parents for x in y.hidden_concepts],
|
|
119
|
+
hidden_concepts=set([x for y in base_parents for x in y.hidden_concepts]),
|
|
120
120
|
)
|
|
121
121
|
|
|
122
122
|
enrichment = set([x.address for x in local_optional])
|
|
@@ -47,7 +47,7 @@ def gen_rowset_node(
|
|
|
47
47
|
return None
|
|
48
48
|
enrichment = set([x.address for x in local_optional])
|
|
49
49
|
rowset_relevant = [x for x in rowset.derived_concepts]
|
|
50
|
-
select_hidden =
|
|
50
|
+
select_hidden = select.hidden_components
|
|
51
51
|
rowset_hidden = [
|
|
52
52
|
x
|
|
53
53
|
for x in rowset.derived_concepts
|
|
@@ -80,7 +80,9 @@ def gen_rowset_node(
|
|
|
80
80
|
for x in node.output_concepts
|
|
81
81
|
if x.address
|
|
82
82
|
not in [
|
|
83
|
-
y
|
|
83
|
+
y
|
|
84
|
+
for y in node.hidden_concepts
|
|
85
|
+
if environment.concepts[y].derivation != PurposeLineage.ROWSET
|
|
84
86
|
]
|
|
85
87
|
],
|
|
86
88
|
)
|
|
@@ -40,9 +40,10 @@ def resolve_concept_map(
|
|
|
40
40
|
for concept in input.output_concepts:
|
|
41
41
|
if concept.address not in input.non_partial_concept_addresses:
|
|
42
42
|
continue
|
|
43
|
-
if
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (
|
|
44
|
+
isinstance(input, QueryDatasource)
|
|
45
|
+
and concept.address in input.hidden_concepts
|
|
46
|
+
):
|
|
46
47
|
continue
|
|
47
48
|
if concept.address in full_addresses:
|
|
48
49
|
concept_map[concept.address].add(input)
|
|
@@ -138,7 +139,7 @@ class StrategyNode:
|
|
|
138
139
|
preexisting_conditions: Conditional | Comparison | Parenthetical | None = None,
|
|
139
140
|
force_group: bool | None = None,
|
|
140
141
|
grain: Optional[Grain] = None,
|
|
141
|
-
hidden_concepts:
|
|
142
|
+
hidden_concepts: set[str] | None = None,
|
|
142
143
|
existence_concepts: List[Concept] | None = None,
|
|
143
144
|
virtual_output_concepts: List[Concept] | None = None,
|
|
144
145
|
):
|
|
@@ -165,7 +166,7 @@ class StrategyNode:
|
|
|
165
166
|
self.grain = grain
|
|
166
167
|
self.force_group = force_group
|
|
167
168
|
self.tainted = False
|
|
168
|
-
self.hidden_concepts = hidden_concepts or
|
|
169
|
+
self.hidden_concepts = hidden_concepts or set()
|
|
169
170
|
self.existence_concepts = existence_concepts or []
|
|
170
171
|
self.virtual_output_concepts = virtual_output_concepts or []
|
|
171
172
|
self.preexisting_conditions = preexisting_conditions
|
|
@@ -281,22 +282,20 @@ class StrategyNode:
|
|
|
281
282
|
|
|
282
283
|
def hide_output_concepts(self, concepts: List[Concept], rebuild: bool = True):
|
|
283
284
|
for x in concepts:
|
|
284
|
-
self.hidden_concepts.
|
|
285
|
+
self.hidden_concepts.add(x.address)
|
|
285
286
|
if rebuild:
|
|
286
287
|
self.rebuild_cache()
|
|
287
288
|
return self
|
|
288
289
|
|
|
289
290
|
def unhide_output_concepts(self, concepts: List[Concept], rebuild: bool = True):
|
|
290
|
-
self.hidden_concepts =
|
|
291
|
-
x for x in self.hidden_concepts if x.address not in concepts
|
|
292
|
-
]
|
|
291
|
+
self.hidden_concepts = set(x for x in self.hidden_concepts if x not in concepts)
|
|
293
292
|
if rebuild:
|
|
294
293
|
self.rebuild_cache()
|
|
295
294
|
return self
|
|
296
295
|
|
|
297
296
|
def remove_output_concepts(self, concepts: List[Concept], rebuild: bool = True):
|
|
298
297
|
for x in concepts:
|
|
299
|
-
self.hidden_concepts.
|
|
298
|
+
self.hidden_concepts.add(x.address)
|
|
300
299
|
addresses = [x.address for x in concepts]
|
|
301
300
|
self.output_concepts = [
|
|
302
301
|
x for x in self.output_concepts if x.address not in addresses
|
|
@@ -388,7 +387,7 @@ class StrategyNode:
|
|
|
388
387
|
preexisting_conditions=self.preexisting_conditions,
|
|
389
388
|
force_group=self.force_group,
|
|
390
389
|
grain=self.grain,
|
|
391
|
-
hidden_concepts=
|
|
390
|
+
hidden_concepts=set(self.hidden_concepts),
|
|
392
391
|
existence_concepts=list(self.existence_concepts),
|
|
393
392
|
virtual_output_concepts=list(self.virtual_output_concepts),
|
|
394
393
|
)
|
|
@@ -48,7 +48,7 @@ class GroupNode(StrategyNode):
|
|
|
48
48
|
conditions: Conditional | Comparison | Parenthetical | None = None,
|
|
49
49
|
preexisting_conditions: Conditional | Comparison | Parenthetical | None = None,
|
|
50
50
|
existence_concepts: List[Concept] | None = None,
|
|
51
|
-
hidden_concepts:
|
|
51
|
+
hidden_concepts: set[str] | None = None,
|
|
52
52
|
):
|
|
53
53
|
super().__init__(
|
|
54
54
|
input_concepts=input_concepts,
|
|
@@ -154,9 +154,9 @@ class GroupNode(StrategyNode):
|
|
|
154
154
|
base.output_concepts + self.conditions.row_arguments, "address"
|
|
155
155
|
)
|
|
156
156
|
# re-visible any hidden concepts
|
|
157
|
-
base.hidden_concepts =
|
|
158
|
-
x for x in base.hidden_concepts if x not in base.output_concepts
|
|
159
|
-
|
|
157
|
+
base.hidden_concepts = set(
|
|
158
|
+
[x for x in base.hidden_concepts if x not in base.output_concepts]
|
|
159
|
+
)
|
|
160
160
|
source_map = resolve_concept_map(
|
|
161
161
|
[base],
|
|
162
162
|
targets=self.output_concepts,
|
|
@@ -191,5 +191,5 @@ class GroupNode(StrategyNode):
|
|
|
191
191
|
conditions=self.conditions,
|
|
192
192
|
preexisting_conditions=self.preexisting_conditions,
|
|
193
193
|
existence_concepts=list(self.existence_concepts),
|
|
194
|
-
hidden_concepts=
|
|
194
|
+
hidden_concepts=set(self.hidden_concepts),
|
|
195
195
|
)
|
|
@@ -115,7 +115,7 @@ class MergeNode(StrategyNode):
|
|
|
115
115
|
grain: Grain | None = None,
|
|
116
116
|
conditions: Conditional | Comparison | Parenthetical | None = None,
|
|
117
117
|
preexisting_conditions: Conditional | Comparison | Parenthetical | None = None,
|
|
118
|
-
hidden_concepts:
|
|
118
|
+
hidden_concepts: set[str] | None = None,
|
|
119
119
|
virtual_output_concepts: List[Concept] | None = None,
|
|
120
120
|
existence_concepts: List[Concept] | None = None,
|
|
121
121
|
):
|
|
@@ -369,7 +369,7 @@ class MergeNode(StrategyNode):
|
|
|
369
369
|
conditions=self.conditions,
|
|
370
370
|
preexisting_conditions=self.preexisting_conditions,
|
|
371
371
|
nullable_concepts=list(self.nullable_concepts),
|
|
372
|
-
hidden_concepts=
|
|
372
|
+
hidden_concepts=set(self.hidden_concepts),
|
|
373
373
|
virtual_output_concepts=list(self.virtual_output_concepts),
|
|
374
374
|
node_joins=list(self.node_joins) if self.node_joins else None,
|
|
375
375
|
join_concepts=list(self.join_concepts) if self.join_concepts else None,
|
|
@@ -45,7 +45,7 @@ class SelectNode(StrategyNode):
|
|
|
45
45
|
force_group: bool | None = False,
|
|
46
46
|
conditions: Conditional | Comparison | Parenthetical | None = None,
|
|
47
47
|
preexisting_conditions: Conditional | Comparison | Parenthetical | None = None,
|
|
48
|
-
hidden_concepts:
|
|
48
|
+
hidden_concepts: set[str] | None = None,
|
|
49
49
|
):
|
|
50
50
|
super().__init__(
|
|
51
51
|
input_concepts=input_concepts,
|
|
@@ -347,7 +347,7 @@ def get_node_joins(
|
|
|
347
347
|
graph.add_node(ds_node, type=NodeType.NODE)
|
|
348
348
|
partials[ds_node] = [f"c~{c.address}" for c in datasource.partial_concepts]
|
|
349
349
|
for concept in datasource.output_concepts:
|
|
350
|
-
if concept in datasource.hidden_concepts:
|
|
350
|
+
if concept.address in datasource.hidden_concepts:
|
|
351
351
|
continue
|
|
352
352
|
add_node_join_concept(
|
|
353
353
|
graph=graph,
|
|
@@ -567,9 +567,8 @@ def find_nullable_concepts(
|
|
|
567
567
|
def sort_select_output_processed(
|
|
568
568
|
cte: CTE | UnionCTE, query: ProcessedQuery
|
|
569
569
|
) -> CTE | UnionCTE:
|
|
570
|
-
hidden_addresses = [c.address for c in query.hidden_columns]
|
|
571
570
|
output_addresses = [
|
|
572
|
-
c.address for c in query.output_columns if c.address not in
|
|
571
|
+
c.address for c in query.output_columns if c.address not in query.hidden_columns
|
|
573
572
|
]
|
|
574
573
|
|
|
575
574
|
mapping = {x.address: x for x in cte.output_columns}
|
|
@@ -586,9 +585,10 @@ def sort_select_output(
|
|
|
586
585
|
) -> CTE | UnionCTE:
|
|
587
586
|
if isinstance(query, ProcessedQuery):
|
|
588
587
|
return sort_select_output_processed(cte, query)
|
|
589
|
-
hidden_addresses = [c.address for c in query.hidden_components]
|
|
590
588
|
output_addresses = [
|
|
591
|
-
c.address
|
|
589
|
+
c.address
|
|
590
|
+
for c in query.output_components
|
|
591
|
+
if c.address not in query.hidden_components
|
|
592
592
|
]
|
|
593
593
|
|
|
594
594
|
mapping = {x.address: x for x in cte.output_columns}
|
trilogy/core/query_processor.py
CHANGED
|
@@ -500,7 +500,7 @@ def process_query(
|
|
|
500
500
|
deduped_ctes: List[CTE | UnionCTE] = list(seen.values())
|
|
501
501
|
root_cte.order_by = statement.order_by
|
|
502
502
|
root_cte.limit = statement.limit
|
|
503
|
-
root_cte.hidden_concepts =
|
|
503
|
+
root_cte.hidden_concepts = statement.hidden_components
|
|
504
504
|
|
|
505
505
|
final_ctes = optimize_ctes(deduped_ctes, root_cte, statement)
|
|
506
506
|
return ProcessedQuery(
|
|
@@ -514,6 +514,6 @@ def process_query(
|
|
|
514
514
|
base=root_cte,
|
|
515
515
|
# we no longer do any joins at final level, this should always happen in parent CTEs
|
|
516
516
|
joins=[],
|
|
517
|
-
hidden_columns=[x for x in statement.hidden_components],
|
|
517
|
+
hidden_columns=set([x for x in statement.hidden_components]),
|
|
518
518
|
local_concepts=statement.local_concepts,
|
|
519
519
|
)
|
trilogy/dialect/base.py
CHANGED
|
@@ -660,7 +660,7 @@ class BaseDialect:
|
|
|
660
660
|
self.render_concept_sql(c, cte)
|
|
661
661
|
for c in cte.output_columns
|
|
662
662
|
if c.address not in [y.address for y in cte.join_derived_concepts]
|
|
663
|
-
and c.address not in
|
|
663
|
+
and c.address not in cte.hidden_concepts
|
|
664
664
|
] + [
|
|
665
665
|
f"{self.QUOTE_CHARACTER}{c.safe_address}{self.QUOTE_CHARACTER}"
|
|
666
666
|
for c in cte.join_derived_concepts
|
|
@@ -670,7 +670,7 @@ class BaseDialect:
|
|
|
670
670
|
select_columns = [
|
|
671
671
|
self.render_concept_sql(c, cte)
|
|
672
672
|
for c in cte.output_columns
|
|
673
|
-
if c.address not in
|
|
673
|
+
if c.address not in cte.hidden_concepts
|
|
674
674
|
]
|
|
675
675
|
if auto_sort:
|
|
676
676
|
select_columns = sorted(select_columns, key=lambda x: x)
|
|
@@ -886,9 +886,10 @@ class BaseDialect:
|
|
|
886
886
|
select_columns: Dict[str, str] = {}
|
|
887
887
|
cte_output_map = {}
|
|
888
888
|
selected = set()
|
|
889
|
-
hidden_addresses = [c.address for c in query.hidden_columns]
|
|
890
889
|
output_addresses = [
|
|
891
|
-
c.address
|
|
890
|
+
c.address
|
|
891
|
+
for c in query.output_columns
|
|
892
|
+
if c.address not in query.hidden_columns
|
|
892
893
|
]
|
|
893
894
|
|
|
894
895
|
for c in query.base.output_columns:
|
|
@@ -897,7 +898,7 @@ class BaseDialect:
|
|
|
897
898
|
f"{query.base.name}.{safe_quote(c.safe_address, self.QUOTE_CHARACTER)}"
|
|
898
899
|
)
|
|
899
900
|
cte_output_map[c.address] = query.base
|
|
900
|
-
if c.address not in
|
|
901
|
+
if c.address not in query.hidden_columns:
|
|
901
902
|
selected.add(c.address)
|
|
902
903
|
if not all([x in selected for x in output_addresses]):
|
|
903
904
|
missing = [x for x in output_addresses if x not in selected]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|