pytrilogy 0.0.1.108__py3-none-any.whl → 0.0.1.109__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytrilogy
3
- Version: 0.0.1.108
3
+ Version: 0.0.1.109
4
4
  Summary: Declarative, typed query language that compiles to SQL.
5
5
  Home-page:
6
6
  Author:
@@ -1,4 +1,4 @@
1
- trilogy/__init__.py,sha256=XUWHIoJWL4bt0ApBe3huE8vvIiYJxxfm4krEBMhpLUc,292
1
+ trilogy/__init__.py,sha256=e2cU9lfgy43E_xTR0vpKBnQaJvz7-8qF7hjum9oQk-k,292
2
2
  trilogy/compiler.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  trilogy/constants.py,sha256=LxiK2TiVQPEa6tXkxWk9DJHOR3zsGNSqgQuqtOf66cw,518
4
4
  trilogy/engine.py,sha256=R5ubIxYyrxRExz07aZCUfrTsoXCHQ8DKFTDsobXdWdA,1102
@@ -16,7 +16,7 @@ trilogy/core/exceptions.py,sha256=NvV_4qLOgKXbpotgRf7c8BANDEvHxlqRPaA53IThQ2o,56
16
16
  trilogy/core/functions.py,sha256=zkRReytiotOBAW-a3Ri5eoejZDYTt2-7Op80ZxZxUmw,9129
17
17
  trilogy/core/graph_models.py,sha256=oJUMSpmYhqXlavckHLpR07GJxuQ8dZ1VbB1fB0KaS8c,2036
18
18
  trilogy/core/internal.py,sha256=jNGFHKENnbMiMCtAgsnLZYVSENDK4b5ALecXFZpTDzQ,1075
19
- trilogy/core/models.py,sha256=JvqqYCQorhHRa7haVRBYCGmmjYq4jWKjOgPqbf2eTNI,109050
19
+ trilogy/core/models.py,sha256=AwVZNiDN1hM0BeEquEyrfTnuVBPDR8UuTnoFUhAaqUo,109648
20
20
  trilogy/core/optimization.py,sha256=chfzpLVJo9eg8H4e2hdnpRqWMDTQ3tJWPdDfGESa-EU,4510
21
21
  trilogy/core/query_processor.py,sha256=6BqLYPwyFkRtueTIRFZi3IcVFTpbpGRNowayhSn3_AY,11805
22
22
  trilogy/core/processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -25,22 +25,22 @@ trilogy/core/processing/graph_utils.py,sha256=ulCJ4hYAISbUxLD6VM2fah9RBPGIXSEHEP
25
25
  trilogy/core/processing/utility.py,sha256=Gk35HgyIG2SSUyI5OHZcB0bw1PZUVC_aNc9Sre6xPQU,10535
26
26
  trilogy/core/processing/node_generators/__init__.py,sha256=LIs6uBEum8LDc-26zjyAwjxa-ay2ok9tKtPjDNvbVkE,757
27
27
  trilogy/core/processing/node_generators/basic_node.py,sha256=tVPmg0r0kDdABkmn6z4sxsk1hKy9yTT_Xvl1eVN2Zck,2162
28
- trilogy/core/processing/node_generators/common.py,sha256=RWaynnlCeF8bhGXVLYWpUFrdngMF95TJwCFue73bXZo,8881
28
+ trilogy/core/processing/node_generators/common.py,sha256=A0zB4xr1etbEexaiSH6mVTecXY_wd7pSwWUGUt-u0eg,8882
29
29
  trilogy/core/processing/node_generators/concept_merge_node.py,sha256=TRbOIjLWfLB0Nl6YmMV1ao0qhPP6OQDd9M3UViWkCBU,6621
30
30
  trilogy/core/processing/node_generators/filter_node.py,sha256=CGALiTzKhPAvXPFAguIQfjf6I3pjlafY0uaaM9MTkIE,3414
31
31
  trilogy/core/processing/node_generators/group_node.py,sha256=xWI1xNIXEOj6jlRGD9hcv2_vVNvY6lpzJl6pQ8HuFBE,2988
32
32
  trilogy/core/processing/node_generators/group_to_node.py,sha256=BzPdYwzoo8gRMH7BDffTTXq4z-mjfCEzvfB5I-P0_nw,2941
33
33
  trilogy/core/processing/node_generators/multiselect_node.py,sha256=vP84dnLQy6dtypi6mUbt9sMAcmmrTgQ1Oz4GI6X1IEo,6421
34
34
  trilogy/core/processing/node_generators/node_merge_node.py,sha256=sQQ9jhw1oAJh649DBAJX6U7r_E_piFS95mxKvm7pxqQ,5818
35
- trilogy/core/processing/node_generators/rowset_node.py,sha256=K-aoLi0OSfNADXR5_vxDcNv2dJeFy30XNp_IaaWWJ6o,4684
35
+ trilogy/core/processing/node_generators/rowset_node.py,sha256=zlSRd58V4fDqz1Km65cWblOrEFpXAT3jlSvv6NKC3pc,4909
36
36
  trilogy/core/processing/node_generators/select_node.py,sha256=xeCqIUEubrf3u_QQfbGdf1BG4fO0HYQ64hiFur8NUqY,20080
37
37
  trilogy/core/processing/node_generators/unnest_node.py,sha256=s1VXQZSf1LnX3ISeQ5JzmzmCKUw30-5OK_f0YTB9_48,1031
38
38
  trilogy/core/processing/node_generators/window_node.py,sha256=ekazi5eXxnShpcp-qukXNG4DHFdULoXrX-YWUWLNEpM,2527
39
39
  trilogy/core/processing/nodes/__init__.py,sha256=gzKxGSduIQ5QwpMWrmwSYiE8sg2mWejwVn0VvjYc6s0,3879
40
- trilogy/core/processing/nodes/base_node.py,sha256=075SP0fAqCZGxxE9Rn5-Qfd2mWd9J7NannGFkNfTkuY,9068
40
+ trilogy/core/processing/nodes/base_node.py,sha256=Du7hRjVVOAiGb0okytzKIa_TQqhwTNYGU8PGNnrE1xs,9142
41
41
  trilogy/core/processing/nodes/filter_node.py,sha256=DqSRv8voEajPZqzeeiIsxuv4ubvsmeQcCW6x_v2CmOk,1359
42
42
  trilogy/core/processing/nodes/group_node.py,sha256=Y_NWB_AwFrE-YithjZ7lYYDN4e0el4su3ICq2EIr3HA,3837
43
- trilogy/core/processing/nodes/merge_node.py,sha256=a9JkWNSb5ikRnr33DJrlIpZ_OXVK7XDF4FFnqNab4wI,12758
43
+ trilogy/core/processing/nodes/merge_node.py,sha256=baLDHCJiX5tk1dsVTm1KebJKPyy1w3WGMfN5wdm0BRw,12759
44
44
  trilogy/core/processing/nodes/select_node_v2.py,sha256=tAADeVruch-flFiedbY1zi7ukMG2RpWecvxxZ5aL3ZU,6354
45
45
  trilogy/core/processing/nodes/unnest_node.py,sha256=t4kY3a_dR3iXistPemStfdw0uJfnxwTcoQg1HiDa3xo,1501
46
46
  trilogy/core/processing/nodes/window_node.py,sha256=QjAWgqBZqFSRCPwc7JBmgQJobWW50rsHI0pjJe0Zzg0,926
@@ -65,13 +65,13 @@ trilogy/parsing/common.py,sha256=lz0IyVA8v-u-DGFgzkmdb4_00I--Kegmo9HNF7CrajI,579
65
65
  trilogy/parsing/config.py,sha256=Z-DaefdKhPDmSXLgg5V4pebhSB0h590vI0_VtHnlukI,111
66
66
  trilogy/parsing/exceptions.py,sha256=92E5i2frv5hj9wxObJZsZqj5T6bglvPzvdvco_vW1Zk,38
67
67
  trilogy/parsing/helpers.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
68
- trilogy/parsing/parse_engine.py,sha256=TLy56pDatDfzfwbJkrJ-XXB05s_VW9_iRrkwtKR0GR4,63860
68
+ trilogy/parsing/parse_engine.py,sha256=iOqKUCyLeHyFVwwAt-XTSJGHia4zzLUN6bYDuIfJ1Pg,63938
69
69
  trilogy/parsing/render.py,sha256=fxjpq2FZLgllw_d4cru-t_IXNPAz2DmYkT7v9ED0XRI,11540
70
70
  trilogy/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
71
  trilogy/scripts/trilogy.py,sha256=PHxvv6f2ODv0esyyhWxlARgra8dVhqQhYl0lTrSyVNo,3729
72
- pytrilogy-0.0.1.108.dist-info/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
73
- pytrilogy-0.0.1.108.dist-info/METADATA,sha256=HUP7pQQZBmSTKuUUioE53ys3fCS76Xjwj2CF5SykMOs,7882
74
- pytrilogy-0.0.1.108.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
75
- pytrilogy-0.0.1.108.dist-info/entry_points.txt,sha256=0petKryjvvtEfTlbZC1AuMFumH_WQ9v8A19LvoS6G6c,54
76
- pytrilogy-0.0.1.108.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
77
- pytrilogy-0.0.1.108.dist-info/RECORD,,
72
+ pytrilogy-0.0.1.109.dist-info/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
73
+ pytrilogy-0.0.1.109.dist-info/METADATA,sha256=-m-LMyjvq4whCY7LpRM9zFqpn3hqH4-DuuP0JYOFfwQ,7882
74
+ pytrilogy-0.0.1.109.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
75
+ pytrilogy-0.0.1.109.dist-info/entry_points.txt,sha256=0petKryjvvtEfTlbZC1AuMFumH_WQ9v8A19LvoS6G6c,54
76
+ pytrilogy-0.0.1.109.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
77
+ pytrilogy-0.0.1.109.dist-info/RECORD,,
trilogy/__init__.py CHANGED
@@ -4,6 +4,6 @@ from trilogy.executor import Executor
4
4
  from trilogy.parser import parse
5
5
  from trilogy.constants import CONFIG
6
6
 
7
- __version__ = "0.0.1.108"
7
+ __version__ = "0.0.1.109"
8
8
 
9
9
  __all__ = ["parse", "Executor", "Dialects", "Environment", "CONFIG"]
trilogy/core/models.py CHANGED
@@ -496,13 +496,31 @@ class Concept(Namespaced, SelectGrain, BaseModel):
496
496
  @property
497
497
  def sources(self) -> List["Concept"]:
498
498
  if self.lineage:
499
- output = []
500
- for item in self.lineage.arguments:
501
- if isinstance(item, Concept):
502
- if item.address == self.address:
503
- raise SyntaxError(f"Concept {self.address} references itself")
504
- output.append(item)
505
- output += item.sources
499
+ output: List[Concept] = []
500
+
501
+ def get_sources(
502
+ expr: Union[
503
+ Function,
504
+ WindowItem,
505
+ FilterItem,
506
+ AggregateWrapper,
507
+ RowsetItem,
508
+ MultiSelectStatement | MergeStatement,
509
+ ],
510
+ output: List[Concept],
511
+ ):
512
+ for item in expr.arguments:
513
+ if isinstance(item, Concept):
514
+ if item.address == self.address:
515
+ raise SyntaxError(
516
+ f"Concept {self.address} references itself"
517
+ )
518
+ output.append(item)
519
+ output += item.sources
520
+ elif isinstance(item, Function):
521
+ get_sources(item, output)
522
+
523
+ get_sources(self.lineage, output)
506
524
  return output
507
525
  return []
508
526
 
@@ -196,6 +196,7 @@ def gen_enrichment_node(
196
196
  log_lambda(
197
197
  f"{str(type(base_node).__name__)} returning merge node with group node + enrichment node"
198
198
  )
199
+
199
200
  return MergeNode(
200
201
  input_concepts=unique(
201
202
  join_keys + extra_required + base_node.output_concepts, "address"
@@ -10,7 +10,7 @@ from trilogy.core.processing.nodes import MergeNode, NodeJoin, History, Strategy
10
10
  from trilogy.core.processing.nodes.base_node import concept_list_to_grain
11
11
  from typing import List
12
12
 
13
- from trilogy.core.enums import JoinType
13
+ from trilogy.core.enums import JoinType, PurposeLineage
14
14
  from trilogy.constants import logger
15
15
  from trilogy.core.processing.utility import padding
16
16
  from trilogy.core.processing.node_generators.common import concept_to_relevant_joins
@@ -53,7 +53,7 @@ def gen_rowset_node(
53
53
  return None
54
54
  node.conditions = select.where_clause.conditional if select.where_clause else None
55
55
  # rebuild any cached info with the new condition clause
56
- node.rebuild_cache()
56
+
57
57
  enrichment = set([x.address for x in local_optional])
58
58
  rowset_relevant = [
59
59
  x
@@ -71,9 +71,15 @@ def gen_rowset_node(
71
71
  if select.where_clause:
72
72
  for item in additional_relevant:
73
73
  node.partial_concepts.append(item)
74
-
74
+ node.hidden_concepts = [
75
+ x
76
+ for x in node.output_concepts
77
+ if x.address not in [y.address for y in local_optional + [concept]]
78
+ and x.derivation != PurposeLineage.ROWSET
79
+ ]
75
80
  # assume grain to be output of select
76
81
  # but don't include anything aggregate at this point
82
+ node.rebuild_cache()
77
83
  assert node.resolution_cache
78
84
  node.resolution_cache.grain = concept_list_to_grain(
79
85
  node.output_concepts, parent_sources=node.resolution_cache.datasources
@@ -184,6 +184,7 @@ class StrategyNode:
184
184
 
185
185
  def rebuild_cache(self) -> QueryDatasource:
186
186
  self.tainted = True
187
+ self.output_lcl = LooseConceptList(concepts=self.output_concepts)
187
188
  if not self.resolution_cache:
188
189
  return self.resolve()
189
190
  self.resolution_cache = None
@@ -207,6 +207,7 @@ class MergeNode(StrategyNode):
207
207
  joins = self.translate_node_joins(final_joins)
208
208
  else:
209
209
  return []
210
+
210
211
  for join in joins:
211
212
  logger.info(
212
213
  f"{self.logging_prefix}{LOGGER_PREFIX} final join {join.join_type} {[str(c) for c in join.concepts]}"
@@ -981,13 +981,13 @@ class ParseToObjects(Transformer):
981
981
 
982
982
  @v_args(meta=True)
983
983
  def merge_statement(self, meta: Meta, args) -> MergeStatement:
984
-
985
984
  parsed = [self.environment.concepts[x] for x in args]
986
985
  datatypes = {x.datatype for x in parsed}
987
- if not len(datatypes) == 1:
986
+ if not len(datatypes) == 1 and self.environment.concepts.fail_on_missing:
987
+ type_dict = {x.address: x.datatype for x in parsed}
988
988
  raise SyntaxError(
989
- f"Cannot merge concepts with different datatypes {datatypes}"
990
- f"line: {meta.line} concepts: {[x.address for x in parsed]}"
989
+ f"Cannot merge concepts with different datatype"
990
+ f"line: {meta.line} concepts: {type_dict}"
991
991
  )
992
992
  merge = MergeStatement(concepts=parsed, datatype=datatypes.pop())
993
993
  new = merge.merge_concept