pytrilogy 0.0.3.45__py3-none-any.whl → 0.0.3.46__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.4
2
2
  Name: pytrilogy
3
- Version: 0.0.3.45
3
+ Version: 0.0.3.46
4
4
  Summary: Declarative, typed query language that compiles to SQL.
5
5
  Home-page:
6
6
  Author:
@@ -1,5 +1,5 @@
1
- pytrilogy-0.0.3.45.dist-info/licenses/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
2
- trilogy/__init__.py,sha256=CExOPBg5voukcSp-h8dQa4Sf1R0iZ0oQBnfggESqllo,303
1
+ pytrilogy-0.0.3.46.dist-info/licenses/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
2
+ trilogy/__init__.py,sha256=YyUmUiX_R4JnFfmRIfKopul0PlCDdGcFxMRUxiSPkp0,303
3
3
  trilogy/compiler.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  trilogy/constants.py,sha256=5eQxk1A0pv-TQk3CCvgZCFA9_K-6nxrOm7E5Lxd7KIY,1652
5
5
  trilogy/engine.py,sha256=OK2RuqCIUId6yZ5hfF8J1nxGP0AJqHRZiafcowmW0xc,1728
@@ -41,7 +41,7 @@ trilogy/core/processing/utility.py,sha256=rfzdgl-vWkCyhLzXNNuWgPLK59eiYypQb6TdZK
41
41
  trilogy/core/processing/node_generators/__init__.py,sha256=o8rOFHPSo-s_59hREwXMW6gjUJCsiXumdbJNozHUf-Y,800
42
42
  trilogy/core/processing/node_generators/basic_node.py,sha256=UVsXMn6jTjm_ofVFt218jAS11s4RV4zD781vP4im-GI,3371
43
43
  trilogy/core/processing/node_generators/common.py,sha256=nVeH_AdO58ygtNSO0wNgMR7_h2D0dFSGM_rh1fJd4Yc,9468
44
- trilogy/core/processing/node_generators/filter_node.py,sha256=lT167yBgy3P9sDBM1Cjj0PKSXro8dvGtBmc8nwsUjig,8366
44
+ trilogy/core/processing/node_generators/filter_node.py,sha256=JymSKzA-9oQAZ3ZtJRK9c3w5FXs8MjJBGWU9TYUqx4E,9099
45
45
  trilogy/core/processing/node_generators/group_node.py,sha256=kO-ersxIL04rZwX5-vFIFQQnp357PFo_7ZKXoGq3wyc,5989
46
46
  trilogy/core/processing/node_generators/group_to_node.py,sha256=jKcNCDOY6fNblrdZwaRU0sbUSr9H0moQbAxrGgX6iGA,3832
47
47
  trilogy/core/processing/node_generators/multiselect_node.py,sha256=GWV5yLmKTe1yyPhN60RG1Rnrn4ktfn9lYYXi_FVU4UI,7061
@@ -102,8 +102,8 @@ trilogy/std/display.preql,sha256=2BbhvqR4rcltyAbOXAUo7SZ_yGFYZgFnurglHMbjW2g,40
102
102
  trilogy/std/geography.preql,sha256=-fqAGnBL6tR-UtT8DbSek3iMFg66ECR_B_41pODxv-k,504
103
103
  trilogy/std/money.preql,sha256=ZHW-csTX-kYbOLmKSO-TcGGgQ-_DMrUXy0BjfuJSFxM,80
104
104
  trilogy/std/report.preql,sha256=LbV-XlHdfw0jgnQ8pV7acG95xrd1-p65fVpiIc-S7W4,202
105
- pytrilogy-0.0.3.45.dist-info/METADATA,sha256=7z2vOsBA8amZQl0YEkjnWFBqxh4amLBZznjHGwZJ6-E,9100
106
- pytrilogy-0.0.3.45.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
107
- pytrilogy-0.0.3.45.dist-info/entry_points.txt,sha256=ewBPU2vLnVexZVnB-NrVj-p3E-4vukg83Zk8A55Wp2w,56
108
- pytrilogy-0.0.3.45.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
109
- pytrilogy-0.0.3.45.dist-info/RECORD,,
105
+ pytrilogy-0.0.3.46.dist-info/METADATA,sha256=1cBYEU3n78eaoNyqLsOS-eP_WylqceEDeFoktS7JzO0,9100
106
+ pytrilogy-0.0.3.46.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
107
+ pytrilogy-0.0.3.46.dist-info/entry_points.txt,sha256=ewBPU2vLnVexZVnB-NrVj-p3E-4vukg83Zk8A55Wp2w,56
108
+ pytrilogy-0.0.3.46.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
109
+ pytrilogy-0.0.3.46.dist-info/RECORD,,
trilogy/__init__.py CHANGED
@@ -4,6 +4,6 @@ from trilogy.dialect.enums import Dialects
4
4
  from trilogy.executor import Executor
5
5
  from trilogy.parser import parse
6
6
 
7
- __version__ = "0.0.3.45"
7
+ __version__ = "0.0.3.46"
8
8
 
9
9
  __all__ = ["parse", "Executor", "Dialects", "Environment", "CONFIG"]
@@ -56,12 +56,40 @@ def gen_filter_node(
56
56
  continue
57
57
  if conditions and conditions == where:
58
58
  optional_included.append(x)
59
+
60
+ # sometimes, it's okay to include other local optional above the filter
61
+ # in case it is, prep our list
62
+ extra_row_level_optional: list[BuildConcept] = []
63
+ for x in local_optional:
64
+ if x.address in optional_included:
65
+ continue
66
+ extra_row_level_optional.append(x)
67
+
68
+ # this flag controls whether we materialize the filter as a where on the prior CTE
69
+ # or do the filtering inline as a case statement
70
+ optimized_pushdown = False
71
+ if not is_scalar_condition(where.conditional):
72
+ optimized_pushdown = False
73
+ elif not local_optional:
74
+ optimized_pushdown = True
75
+ elif conditions and conditions == where:
76
+ logger.info(
77
+ f"{padding(depth)}{LOGGER_PREFIX} query conditions are the same as filter conditions, can optimize across all concepts"
78
+ )
79
+ optimized_pushdown = True
80
+ elif optional_included == local_optional:
81
+ logger.info(
82
+ f"{padding(depth)}{LOGGER_PREFIX} all optional concepts are included in the filter, can optimize across all concepts"
83
+ )
84
+ optimized_pushdown = True
59
85
  logger.info(
60
86
  f"{padding(depth)}{LOGGER_PREFIX} filter `{concept}` condition `{concept.lineage.where}` derived from {immediate_parent.address} row parents {[x.address for x in parent_row_concepts]} and {[[y.address] for x in parent_existence_concepts for y in x]} existence parents"
61
87
  )
62
88
  # we'll populate this with the row parent
63
89
  # and the existence parent(s)
64
90
  core_parents = []
91
+ if not optimized_pushdown:
92
+ parent_row_concepts += extra_row_level_optional
65
93
 
66
94
  row_parent: StrategyNode = source_concepts(
67
95
  mandatory_list=parent_row_concepts,
@@ -99,21 +127,6 @@ def gen_filter_node(
99
127
  )
100
128
  return None
101
129
 
102
- optimized_pushdown = False
103
- if not is_scalar_condition(where.conditional):
104
- optimized_pushdown = False
105
- elif not local_optional:
106
- optimized_pushdown = True
107
- elif conditions and conditions == where:
108
- logger.info(
109
- f"{padding(depth)}{LOGGER_PREFIX} query conditions are the same as filter conditions, can optimize across all concepts"
110
- )
111
- optimized_pushdown = True
112
- elif optional_included == local_optional:
113
- logger.info(
114
- f"{padding(depth)}{LOGGER_PREFIX} all optional concepts are included in the filter, can optimize across all concepts"
115
- )
116
- optimized_pushdown = True
117
130
  if optimized_pushdown:
118
131
  logger.info(
119
132
  f"{padding(depth)}{LOGGER_PREFIX} returning optimized filter node with pushdown to parent with condition {where.conditional}"
@@ -193,7 +206,9 @@ def gen_filter_node(
193
206
  + optional_outputs
194
207
  )
195
208
  return filter_node
196
-
209
+ logger.info(
210
+ f"{padding(depth)}{LOGGER_PREFIX} need to enrich filter node with additional concepts {[x.address for x in local_optional if x.address not in filter_node.output_concepts]}"
211
+ )
197
212
  enrich_node: StrategyNode = source_concepts( # this fetches the parent + join keys
198
213
  # to then connect to the rest of the query
199
214
  mandatory_list=[immediate_parent] + parent_row_concepts + local_optional,