pytrilogy 0.0.3.113__py3-none-any.whl → 0.0.3.116__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.113.dist-info → pytrilogy-0.0.3.116.dist-info}/METADATA +1 -1
- {pytrilogy-0.0.3.113.dist-info → pytrilogy-0.0.3.116.dist-info}/RECORD +30 -30
- trilogy/__init__.py +1 -1
- trilogy/constants.py +29 -0
- trilogy/core/enums.py +6 -1
- trilogy/core/functions.py +33 -0
- trilogy/core/models/author.py +126 -2
- trilogy/core/models/build.py +70 -7
- trilogy/core/models/environment.py +2 -1
- trilogy/core/optimization.py +3 -2
- trilogy/core/optimizations/hide_unused_concept.py +1 -5
- trilogy/core/processing/concept_strategies_v3.py +26 -5
- trilogy/core/processing/discovery_node_factory.py +2 -2
- trilogy/core/processing/discovery_utility.py +11 -4
- trilogy/core/processing/node_generators/basic_node.py +26 -15
- trilogy/core/processing/node_generators/common.py +4 -1
- trilogy/core/processing/node_generators/filter_node.py +7 -0
- trilogy/core/processing/node_generators/multiselect_node.py +3 -3
- trilogy/core/processing/node_generators/unnest_node.py +77 -6
- trilogy/core/statements/author.py +4 -1
- trilogy/dialect/base.py +42 -2
- trilogy/executor.py +1 -1
- trilogy/parsing/common.py +117 -20
- trilogy/parsing/parse_engine.py +115 -5
- trilogy/parsing/render.py +2 -1
- trilogy/parsing/trilogy.lark +20 -7
- {pytrilogy-0.0.3.113.dist-info → pytrilogy-0.0.3.116.dist-info}/WHEEL +0 -0
- {pytrilogy-0.0.3.113.dist-info → pytrilogy-0.0.3.116.dist-info}/entry_points.txt +0 -0
- {pytrilogy-0.0.3.113.dist-info → pytrilogy-0.0.3.116.dist-info}/licenses/LICENSE.md +0 -0
- {pytrilogy-0.0.3.113.dist-info → pytrilogy-0.0.3.116.dist-info}/top_level.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
pytrilogy-0.0.3.
|
|
2
|
-
trilogy/__init__.py,sha256=
|
|
3
|
-
trilogy/constants.py,sha256=
|
|
1
|
+
pytrilogy-0.0.3.116.dist-info/licenses/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
|
|
2
|
+
trilogy/__init__.py,sha256=4zCLL3ve6Z14PQ3LocAoJnyiTflxDn90gE8yUR-T9-w,304
|
|
3
|
+
trilogy/constants.py,sha256=_Tm7YGaAZuxH77X5ve0TajU0dQD7RcGV6ECrTHRL3qQ,2678
|
|
4
4
|
trilogy/engine.py,sha256=v4TpNktM4zZ9OX7jZH2nde4dpX5uAH2U23ELfULTCSg,2280
|
|
5
|
-
trilogy/executor.py,sha256=
|
|
5
|
+
trilogy/executor.py,sha256=uKlCnPp4FHkgsa_dDcQJ4y-ObtvKat2KFx05c-z1mZo,17885
|
|
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
|
|
@@ -23,45 +23,45 @@ trilogy/ai/providers/utils.py,sha256=yttP6y2E_XzdytBCwhaKekfXfxM6gE6MRce4AtyLL60
|
|
|
23
23
|
trilogy/authoring/__init__.py,sha256=TABMOETSMERrWuyDLR0nK4ISlqR0yaqeXrmuOdrSvAY,3060
|
|
24
24
|
trilogy/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
trilogy/core/constants.py,sha256=nizWYDCJQ1bigQMtkNIEMNTcN0NoEAXiIHLzpelxQ24,201
|
|
26
|
-
trilogy/core/enums.py,sha256=
|
|
26
|
+
trilogy/core/enums.py,sha256=SkuyRrqqS59LO08CWwbFaZ5kYw_w0WWWcigd9MSXdaA,9082
|
|
27
27
|
trilogy/core/env_processor.py,sha256=H-rr2ALj31l5oh3FqeI47Qju6OOfiXBacXNJGNZ92zQ,4521
|
|
28
28
|
trilogy/core/environment_helpers.py,sha256=TRlqVctqIRBxzfjRBmpQsAVoiCcsEKBhG1B6PUE0l1M,12743
|
|
29
29
|
trilogy/core/ergonomics.py,sha256=e-7gE29vPLFdg0_A1smQ7eOrUwKl5VYdxRSTddHweRA,1631
|
|
30
30
|
trilogy/core/exceptions.py,sha256=axkVXYJYQXCCwMHwlyDA232g4tCOwdCZUt7eHeUMDMg,2829
|
|
31
|
-
trilogy/core/functions.py,sha256=
|
|
31
|
+
trilogy/core/functions.py,sha256=QidWH7dDjvLjXA0ujCkemUzYjkYmtMD2T78hnvk86K8,34876
|
|
32
32
|
trilogy/core/graph_models.py,sha256=4EWFTHGfYd72zvS2HYoV6hm7nMC_VEd7vWr6txY-ig0,3400
|
|
33
33
|
trilogy/core/internal.py,sha256=r9QagDB2GvpqlyD_I7VrsfbVfIk5mnok2znEbv72Aa4,2681
|
|
34
|
-
trilogy/core/optimization.py,sha256=
|
|
34
|
+
trilogy/core/optimization.py,sha256=eKieOaWXUtoNTVQbThGA5tqrI06ZR6SUFOqGe4Jw0k4,9262
|
|
35
35
|
trilogy/core/query_processor.py,sha256=rMrtLSQxVm7yeyh0nWjDNI9nnu4Xi0NgHvBJ14gvu4I,20384
|
|
36
36
|
trilogy/core/utility.py,sha256=3VC13uSQWcZNghgt7Ot0ZTeEmNqs__cx122abVq9qhM,410
|
|
37
37
|
trilogy/core/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
-
trilogy/core/models/author.py,sha256=
|
|
39
|
-
trilogy/core/models/build.py,sha256=
|
|
38
|
+
trilogy/core/models/author.py,sha256=YnBwxanbn9uBAExz5POM0_RFw9GIHmjfLZRVzA10Gws,85862
|
|
39
|
+
trilogy/core/models/build.py,sha256=zVHD8jo8V8E0aGWtobzXG7hY3VjLChiW4s1QBx9sD5k,72938
|
|
40
40
|
trilogy/core/models/build_environment.py,sha256=mpx7MKGc60fnZLVdeLi2YSREy7eQbQYycCrP4zF-rHU,5258
|
|
41
41
|
trilogy/core/models/core.py,sha256=iT9WdZoiXeglmUHWn6bZyXCTBpkApTGPKtNm_Mhbu_g,12987
|
|
42
42
|
trilogy/core/models/datasource.py,sha256=wogTevZ-9CyUW2a8gjzqMCieircxi-J5lkI7EOAZnck,9596
|
|
43
|
-
trilogy/core/models/environment.py,sha256
|
|
43
|
+
trilogy/core/models/environment.py,sha256=-r6_imqkJ10iPTbWGrdfeF2Th480UKLsG8ihACyqO8w,28823
|
|
44
44
|
trilogy/core/models/execute.py,sha256=3fgEdho2e7S0outq91cCzb9jFwz6L1hTbsTrJwGvIFs,42311
|
|
45
45
|
trilogy/core/optimizations/__init__.py,sha256=yspWc25M5SgAuvXYoSt5J8atyPbDlOfsKjIo5yGD9s4,368
|
|
46
46
|
trilogy/core/optimizations/base_optimization.py,sha256=gzDOKImoFn36k7XBD3ysEYDnbnb6vdVIztUfFQZsGnM,513
|
|
47
|
-
trilogy/core/optimizations/hide_unused_concept.py,sha256=
|
|
47
|
+
trilogy/core/optimizations/hide_unused_concept.py,sha256=THp6byyh64dArSz6EuY7unik5WKgQQfWxNGToEqjqE0,1875
|
|
48
48
|
trilogy/core/optimizations/inline_datasource.py,sha256=2sWNRpoRInnTgo9wExVT_r9RfLAQHI57reEV5cGHUcg,4329
|
|
49
49
|
trilogy/core/optimizations/predicate_pushdown.py,sha256=5ubatgq1IwWQ4L2FDt4--y168YLuGP-vwqH0m8IeTIw,9786
|
|
50
50
|
trilogy/core/processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
|
-
trilogy/core/processing/concept_strategies_v3.py,sha256
|
|
52
|
-
trilogy/core/processing/discovery_node_factory.py,sha256=
|
|
53
|
-
trilogy/core/processing/discovery_utility.py,sha256=
|
|
51
|
+
trilogy/core/processing/concept_strategies_v3.py,sha256=MBQeJGBDW2w3xxwano43-5MVBqfbIU9M3K7RFbnSKNA,23367
|
|
52
|
+
trilogy/core/processing/discovery_node_factory.py,sha256=llnLxZo1NqBRIuuPz0GUohym6LZFhVkPT3xSiORi3k4,15446
|
|
53
|
+
trilogy/core/processing/discovery_utility.py,sha256=mO0npZMRlQSzxt3l4m8garKBAOrXFkzt3eiiUyUSoIU,13528
|
|
54
54
|
trilogy/core/processing/discovery_validation.py,sha256=eZ4HfHMpqZLI8MGG2jez8arS8THs6ceuVrQFIY6gXrU,5364
|
|
55
55
|
trilogy/core/processing/graph_utils.py,sha256=8QUVrkE9j-9C1AyrCb1nQEh8daCe0u1HuXl-Te85lag,1205
|
|
56
56
|
trilogy/core/processing/utility.py,sha256=ESs6pKqVP2c9eMdfB2JNjw7D7YnoezVwbLFx1D6OUYA,26088
|
|
57
57
|
trilogy/core/processing/node_generators/__init__.py,sha256=iVJ-crowPxYeut-hFjyEjfibKIDq7PfB4LEuDAUCjGY,943
|
|
58
|
-
trilogy/core/processing/node_generators/basic_node.py,sha256=
|
|
59
|
-
trilogy/core/processing/node_generators/common.py,sha256=
|
|
58
|
+
trilogy/core/processing/node_generators/basic_node.py,sha256=IeR00MV6Ay1TDuebcbwNTp1WC9kT23_JIWYpeUqtn_M,5992
|
|
59
|
+
trilogy/core/processing/node_generators/common.py,sha256=oGUW4_RhSpfGu9PNUj0JsHB8iMeTz76FQHMcfVRHP30,9516
|
|
60
60
|
trilogy/core/processing/node_generators/constant_node.py,sha256=LfpDq2WrBRZ3tGsLxw77LuigKfhbteWWh9L8BGdMGwk,1146
|
|
61
|
-
trilogy/core/processing/node_generators/filter_node.py,sha256=
|
|
61
|
+
trilogy/core/processing/node_generators/filter_node.py,sha256=EiP_tafx-X0gM-BIVRCy2rnp1_apt2cbhVfv8cg9dVg,11259
|
|
62
62
|
trilogy/core/processing/node_generators/group_node.py,sha256=sIm1QYrF4EY6sk56A48B6MieCZqvaJLSQebih_aiKnQ,8567
|
|
63
63
|
trilogy/core/processing/node_generators/group_to_node.py,sha256=jKcNCDOY6fNblrdZwaRU0sbUSr9H0moQbAxrGgX6iGA,3832
|
|
64
|
-
trilogy/core/processing/node_generators/multiselect_node.py,sha256=
|
|
64
|
+
trilogy/core/processing/node_generators/multiselect_node.py,sha256=qrgx8ofExbigipFBXKufu279vKWBLSBP91TyJW6g1qE,7135
|
|
65
65
|
trilogy/core/processing/node_generators/node_merge_node.py,sha256=hNcZxnDLTZyYJWfojg769zH9HB9PfZfESmpN1lcHWXg,23172
|
|
66
66
|
trilogy/core/processing/node_generators/recursive_node.py,sha256=l5zdh0dURKwmAy8kK4OpMtZfyUEQRk6N-PwSWIyBpSM,2468
|
|
67
67
|
trilogy/core/processing/node_generators/rowset_node.py,sha256=MuVNIexXhqGONho_mewqMOwaYXNUnjjvyPvk_RDGNYE,5943
|
|
@@ -69,7 +69,7 @@ trilogy/core/processing/node_generators/select_merge_node.py,sha256=9MZdQJtkoe5N
|
|
|
69
69
|
trilogy/core/processing/node_generators/select_node.py,sha256=Ta1G39V94gjX_AgyZDz9OqnwLz4BjY3D6Drx9YpziMQ,3555
|
|
70
70
|
trilogy/core/processing/node_generators/synonym_node.py,sha256=AnAsa_Wj50NJ_IK0HSgab_7klYmKVrv0WI1uUe-GvEY,3766
|
|
71
71
|
trilogy/core/processing/node_generators/union_node.py,sha256=NxQbnRRoYMI4WjMeph41yk4E6yipj53qdGuNt-Mozxw,2818
|
|
72
|
-
trilogy/core/processing/node_generators/unnest_node.py,sha256=
|
|
72
|
+
trilogy/core/processing/node_generators/unnest_node.py,sha256=Q9E6MF6uVLqP15tlx_Bwa6mIWSNW68LJpkSYyr_TArs,6229
|
|
73
73
|
trilogy/core/processing/node_generators/window_node.py,sha256=wNvmumGO6AIQ7C9bDUYYZ6LJvDvPQPfFVX82pTxjV-k,6767
|
|
74
74
|
trilogy/core/processing/node_generators/select_helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
75
75
|
trilogy/core/processing/node_generators/select_helpers/datasource_injection.py,sha256=m2YQ4OmG0N2O61a7NEq1ZzbTa7JsCC00lxB2ymjcYRI,8224
|
|
@@ -84,7 +84,7 @@ trilogy/core/processing/nodes/union_node.py,sha256=hLAXXVWqEgMWi7dlgSHfCF59fon64
|
|
|
84
84
|
trilogy/core/processing/nodes/unnest_node.py,sha256=oLKMMNMx6PLDPlt2V5neFMFrFWxET8r6XZElAhSNkO0,2181
|
|
85
85
|
trilogy/core/processing/nodes/window_node.py,sha256=JXJ0iVRlSEM2IBr1TANym2RaUf_p5E_l2sNykRzXWDo,1710
|
|
86
86
|
trilogy/core/statements/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
87
|
-
trilogy/core/statements/author.py,sha256=
|
|
87
|
+
trilogy/core/statements/author.py,sha256=uEYJ9Q39TdGP0cxQEv3Ue4pGp_dmZ-NiT6k2-rfZERQ,16525
|
|
88
88
|
trilogy/core/statements/build.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
89
89
|
trilogy/core/statements/common.py,sha256=VnVLULQg1TJLNUFzJaROT1tsf2ewk3IpuhvZaP36R6A,535
|
|
90
90
|
trilogy/core/statements/execute.py,sha256=kiwJcVeMa4wZR-xLfM2oYOJ9DeyJkP8An38WFyJxktM,2413
|
|
@@ -95,7 +95,7 @@ trilogy/core/validation/datasource.py,sha256=nJeEFyb6iMBwlEVdYVy1vLzAbdRZwOsUjGx
|
|
|
95
95
|
trilogy/core/validation/environment.py,sha256=ymvhQyt7jLK641JAAIQkqjQaAmr9C5022ILzYvDgPP0,2835
|
|
96
96
|
trilogy/core/validation/fix.py,sha256=Z818UFNLxndMTLiyhB3doLxIfnOZ-16QGvVFWuD7UsA,3750
|
|
97
97
|
trilogy/dialect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
98
|
-
trilogy/dialect/base.py,sha256=
|
|
98
|
+
trilogy/dialect/base.py,sha256=i_rdrO3TmKYZK4K8k6ggpvRmzaCl1oR65n89_yHNEPo,52445
|
|
99
99
|
trilogy/dialect/bigquery.py,sha256=XS3hpybeowgfrOrkycAigAF3NX2YUzTzfgE6f__2fT4,4316
|
|
100
100
|
trilogy/dialect/common.py,sha256=I5Ku_TR5MwJTB3ZhcQenrtvXhH2RvTQ8wQe9w5lfkfA,5708
|
|
101
101
|
trilogy/dialect/config.py,sha256=olnyeVU5W5T6b9-dMeNAnvxuPlyc2uefb7FRME094Ec,3834
|
|
@@ -113,13 +113,13 @@ trilogy/hooks/graph_hook.py,sha256=5BfR7Dt0bgEsCLgwjowgCsVkboGYfVJGOz8g9mqpnos,4
|
|
|
113
113
|
trilogy/hooks/query_debugger.py,sha256=1npRjww94sPV5RRBBlLqMJRaFkH9vhEY6o828MeoEcw,5583
|
|
114
114
|
trilogy/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
115
115
|
trilogy/parsing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
116
|
-
trilogy/parsing/common.py,sha256=
|
|
116
|
+
trilogy/parsing/common.py,sha256=GijDRpysULL6vQWpFcjgxVASuTWXUVUi5fILHvjzkbg,35534
|
|
117
117
|
trilogy/parsing/config.py,sha256=Z-DaefdKhPDmSXLgg5V4pebhSB0h590vI0_VtHnlukI,111
|
|
118
118
|
trilogy/parsing/exceptions.py,sha256=Xwwsv2C9kSNv2q-HrrKC1f60JNHShXcCMzstTSEbiCw,154
|
|
119
119
|
trilogy/parsing/helpers.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
120
|
-
trilogy/parsing/parse_engine.py,sha256=
|
|
121
|
-
trilogy/parsing/render.py,sha256=
|
|
122
|
-
trilogy/parsing/trilogy.lark,sha256=
|
|
120
|
+
trilogy/parsing/parse_engine.py,sha256=iHBRUatv4hXSdDgAjllgTe1OtD8WE7V0Gu-ZTT2YugY,86301
|
|
121
|
+
trilogy/parsing/render.py,sha256=k7MNp8EBTqVBSVqFlgTHSwIhfSKLyJfSeb2fSbt9dVA,24307
|
|
122
|
+
trilogy/parsing/trilogy.lark,sha256=6nQ4fLpiL0pNMAlmmIEwN8Am4DlIIYpBVajp4jHveA8,17185
|
|
123
123
|
trilogy/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
124
124
|
trilogy/scripts/trilogy.py,sha256=1L0XrH4mVHRt1C9T1HnaDv2_kYEfbWTb5_-cBBke79w,3774
|
|
125
125
|
trilogy/std/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -132,8 +132,8 @@ trilogy/std/money.preql,sha256=XWwvAV3WxBsHX9zfptoYRnBigcfYwrYtBHXTME0xJuQ,2082
|
|
|
132
132
|
trilogy/std/net.preql,sha256=WZCuvH87_rZntZiuGJMmBDMVKkdhTtxeHOkrXNwJ1EE,416
|
|
133
133
|
trilogy/std/ranking.preql,sha256=LDoZrYyz4g3xsII9XwXfmstZD-_92i1Eox1UqkBIfi8,83
|
|
134
134
|
trilogy/std/report.preql,sha256=LbV-XlHdfw0jgnQ8pV7acG95xrd1-p65fVpiIc-S7W4,202
|
|
135
|
-
pytrilogy-0.0.3.
|
|
136
|
-
pytrilogy-0.0.3.
|
|
137
|
-
pytrilogy-0.0.3.
|
|
138
|
-
pytrilogy-0.0.3.
|
|
139
|
-
pytrilogy-0.0.3.
|
|
135
|
+
pytrilogy-0.0.3.116.dist-info/METADATA,sha256=N3aeyGXHRF0etmB8YiAXUHOfidTmQgqDcxUm8enTumw,12911
|
|
136
|
+
pytrilogy-0.0.3.116.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
137
|
+
pytrilogy-0.0.3.116.dist-info/entry_points.txt,sha256=ewBPU2vLnVexZVnB-NrVj-p3E-4vukg83Zk8A55Wp2w,56
|
|
138
|
+
pytrilogy-0.0.3.116.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
|
|
139
|
+
pytrilogy-0.0.3.116.dist-info/RECORD,,
|
trilogy/__init__.py
CHANGED
trilogy/constants.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import random
|
|
2
|
+
from contextlib import contextmanager
|
|
2
3
|
from dataclasses import dataclass, field
|
|
3
4
|
from enum import Enum
|
|
4
5
|
from logging import getLogger
|
|
6
|
+
from typing import Any
|
|
5
7
|
|
|
6
8
|
logger = getLogger("trilogy")
|
|
7
9
|
|
|
@@ -29,6 +31,7 @@ class Optimizations:
|
|
|
29
31
|
constant_inlining: bool = True
|
|
30
32
|
constant_inline_cutoff: int = 10
|
|
31
33
|
direct_return: bool = True
|
|
34
|
+
hide_unused_concepts: bool = True
|
|
32
35
|
|
|
33
36
|
|
|
34
37
|
@dataclass
|
|
@@ -50,6 +53,32 @@ class Rendering:
|
|
|
50
53
|
parameters: bool = True
|
|
51
54
|
concise: bool = False
|
|
52
55
|
|
|
56
|
+
@contextmanager
|
|
57
|
+
def temporary(self, **kwargs: Any):
|
|
58
|
+
"""
|
|
59
|
+
Context manager to temporarily set attributes and revert them afterwards.
|
|
60
|
+
|
|
61
|
+
Usage:
|
|
62
|
+
r = Rendering()
|
|
63
|
+
with r.temporary(parameters=False, concise=True):
|
|
64
|
+
# parameters is False, concise is True here
|
|
65
|
+
do_something()
|
|
66
|
+
# parameters and concise are back to their original values
|
|
67
|
+
"""
|
|
68
|
+
# Store original values
|
|
69
|
+
original_values = {key: getattr(self, key) for key in kwargs}
|
|
70
|
+
|
|
71
|
+
# Set new values
|
|
72
|
+
for key, value in kwargs.items():
|
|
73
|
+
setattr(self, key, value)
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
yield self
|
|
77
|
+
finally:
|
|
78
|
+
# Restore original values
|
|
79
|
+
for key, value in original_values.items():
|
|
80
|
+
setattr(self, key, value)
|
|
81
|
+
|
|
53
82
|
|
|
54
83
|
@dataclass
|
|
55
84
|
class Parsing:
|
trilogy/core/enums.py
CHANGED
|
@@ -169,6 +169,7 @@ class FunctionType(Enum):
|
|
|
169
169
|
ARRAY_SORT = "array_sort"
|
|
170
170
|
ARRAY_TRANSFORM = "array_transform"
|
|
171
171
|
ARRAY_TO_STRING = "array_to_string"
|
|
172
|
+
ARRAY_FILTER = "array_filter"
|
|
172
173
|
|
|
173
174
|
# MAP
|
|
174
175
|
MAP_KEYS = "map_keys"
|
|
@@ -204,6 +205,7 @@ class FunctionType(Enum):
|
|
|
204
205
|
MIN = "min"
|
|
205
206
|
AVG = "avg"
|
|
206
207
|
ARRAY_AGG = "array_agg"
|
|
208
|
+
ANY = "any"
|
|
207
209
|
|
|
208
210
|
# String
|
|
209
211
|
LIKE = "like"
|
|
@@ -215,6 +217,7 @@ class FunctionType(Enum):
|
|
|
215
217
|
CONTAINS = "contains"
|
|
216
218
|
TRIM = "trim"
|
|
217
219
|
REPLACE = "replace"
|
|
220
|
+
HASH = "hash"
|
|
218
221
|
|
|
219
222
|
# STRING REGEX
|
|
220
223
|
REGEXP_CONTAINS = "regexp_contains"
|
|
@@ -244,6 +247,7 @@ class FunctionType(Enum):
|
|
|
244
247
|
DATE_ADD = "date_add"
|
|
245
248
|
DATE_SUB = "date_sub"
|
|
246
249
|
DATE_DIFF = "date_diff"
|
|
250
|
+
DATE_SPINE = "date_spine"
|
|
247
251
|
|
|
248
252
|
# UNIX
|
|
249
253
|
UNIX_TO_TIMESTAMP = "unix_to_timestamp"
|
|
@@ -263,6 +267,7 @@ class FunctionClass(Enum):
|
|
|
263
267
|
FunctionType.ARRAY_AGG,
|
|
264
268
|
FunctionType.COUNT,
|
|
265
269
|
FunctionType.COUNT_DISTINCT,
|
|
270
|
+
FunctionType.ANY,
|
|
266
271
|
]
|
|
267
272
|
SINGLE_ROW = [
|
|
268
273
|
FunctionType.CONSTANT,
|
|
@@ -270,7 +275,7 @@ class FunctionClass(Enum):
|
|
|
270
275
|
FunctionType.CURRENT_DATETIME,
|
|
271
276
|
]
|
|
272
277
|
|
|
273
|
-
ONE_TO_MANY = [FunctionType.UNNEST]
|
|
278
|
+
ONE_TO_MANY = [FunctionType.UNNEST, FunctionType.DATE_SPINE]
|
|
274
279
|
|
|
275
280
|
RECURSIVE = [FunctionType.RECURSE_EDGE]
|
|
276
281
|
|
trilogy/core/functions.py
CHANGED
|
@@ -212,6 +212,14 @@ FUNCTION_REGISTRY: dict[FunctionType, FunctionConfig] = {
|
|
|
212
212
|
output_type_function=get_unnest_output_type,
|
|
213
213
|
arg_count=1,
|
|
214
214
|
),
|
|
215
|
+
FunctionType.DATE_SPINE: FunctionConfig(
|
|
216
|
+
valid_inputs={
|
|
217
|
+
DataType.DATE,
|
|
218
|
+
},
|
|
219
|
+
output_purpose=Purpose.KEY,
|
|
220
|
+
output_type=DataType.DATE,
|
|
221
|
+
arg_count=2,
|
|
222
|
+
),
|
|
215
223
|
FunctionType.RECURSE_EDGE: FunctionConfig(
|
|
216
224
|
arg_count=2,
|
|
217
225
|
),
|
|
@@ -318,6 +326,18 @@ FUNCTION_REGISTRY: dict[FunctionType, FunctionConfig] = {
|
|
|
318
326
|
output_type_function=get_transform_output_type,
|
|
319
327
|
arg_count=3,
|
|
320
328
|
),
|
|
329
|
+
FunctionType.ARRAY_FILTER: FunctionConfig(
|
|
330
|
+
valid_inputs=[
|
|
331
|
+
{
|
|
332
|
+
DataType.ARRAY,
|
|
333
|
+
},
|
|
334
|
+
{*DataType},
|
|
335
|
+
{*DataType},
|
|
336
|
+
],
|
|
337
|
+
output_purpose=Purpose.PROPERTY,
|
|
338
|
+
output_type_function=get_transform_output_type,
|
|
339
|
+
arg_count=3,
|
|
340
|
+
),
|
|
321
341
|
FunctionType.ARRAY_TO_STRING: FunctionConfig(
|
|
322
342
|
valid_inputs={
|
|
323
343
|
DataType.ARRAY,
|
|
@@ -887,6 +907,11 @@ FUNCTION_REGISTRY: dict[FunctionType, FunctionConfig] = {
|
|
|
887
907
|
),
|
|
888
908
|
arg_count=1,
|
|
889
909
|
),
|
|
910
|
+
FunctionType.ANY: FunctionConfig(
|
|
911
|
+
valid_inputs={*DataType},
|
|
912
|
+
output_purpose=Purpose.PROPERTY,
|
|
913
|
+
arg_count=1,
|
|
914
|
+
),
|
|
890
915
|
FunctionType.AVG: FunctionConfig(
|
|
891
916
|
valid_inputs={
|
|
892
917
|
DataType.INTEGER,
|
|
@@ -903,6 +928,14 @@ FUNCTION_REGISTRY: dict[FunctionType, FunctionConfig] = {
|
|
|
903
928
|
output_type=DataType.TIMESTAMP,
|
|
904
929
|
arg_count=1,
|
|
905
930
|
),
|
|
931
|
+
FunctionType.HASH: FunctionConfig(
|
|
932
|
+
valid_inputs={
|
|
933
|
+
DataType.STRING,
|
|
934
|
+
},
|
|
935
|
+
output_purpose=Purpose.PROPERTY,
|
|
936
|
+
output_type=DataType.STRING,
|
|
937
|
+
arg_count=2,
|
|
938
|
+
),
|
|
906
939
|
}
|
|
907
940
|
|
|
908
941
|
EXCLUDED_FUNCTIONS = {
|
trilogy/core/models/author.py
CHANGED
|
@@ -865,6 +865,7 @@ class Concept(Addressable, DataTyped, ConceptArgs, Mergeable, Namespaced, BaseMo
|
|
|
865
865
|
AggregateWrapper,
|
|
866
866
|
RowsetItem,
|
|
867
867
|
MultiSelectLineage,
|
|
868
|
+
Comparison,
|
|
868
869
|
]
|
|
869
870
|
] = None
|
|
870
871
|
namespace: str = Field(default=DEFAULT_NAMESPACE, validate_default=True)
|
|
@@ -1079,6 +1080,7 @@ class Concept(Addressable, DataTyped, ConceptArgs, Mergeable, Namespaced, BaseMo
|
|
|
1079
1080
|
| AggregateWrapper
|
|
1080
1081
|
| RowsetItem
|
|
1081
1082
|
| MultiSelectLineage
|
|
1083
|
+
| Comparison
|
|
1082
1084
|
| None,
|
|
1083
1085
|
Grain,
|
|
1084
1086
|
set[str] | None,
|
|
@@ -1178,6 +1180,7 @@ class Concept(Addressable, DataTyped, ConceptArgs, Mergeable, Namespaced, BaseMo
|
|
|
1178
1180
|
AggregateWrapper,
|
|
1179
1181
|
RowsetItem,
|
|
1180
1182
|
MultiSelectLineage,
|
|
1183
|
+
Comparison,
|
|
1181
1184
|
],
|
|
1182
1185
|
output: List[ConceptRef],
|
|
1183
1186
|
):
|
|
@@ -1204,6 +1207,7 @@ class Concept(Addressable, DataTyped, ConceptArgs, Mergeable, Namespaced, BaseMo
|
|
|
1204
1207
|
def calculate_derivation(self, lineage, purpose: Purpose) -> Derivation:
|
|
1205
1208
|
from trilogy.core.models.build import (
|
|
1206
1209
|
BuildAggregateWrapper,
|
|
1210
|
+
BuildComparison,
|
|
1207
1211
|
BuildFilterItem,
|
|
1208
1212
|
BuildFunction,
|
|
1209
1213
|
BuildMultiSelectLineage,
|
|
@@ -1221,6 +1225,8 @@ class Concept(Addressable, DataTyped, ConceptArgs, Mergeable, Namespaced, BaseMo
|
|
|
1221
1225
|
# return Derivation.PARENTHETICAL
|
|
1222
1226
|
elif lineage and isinstance(lineage, (BuildRowsetItem, RowsetItem)):
|
|
1223
1227
|
return Derivation.ROWSET
|
|
1228
|
+
elif lineage and isinstance(lineage, BuildComparison):
|
|
1229
|
+
return Derivation.BASIC
|
|
1224
1230
|
elif lineage and isinstance(
|
|
1225
1231
|
lineage, (BuildMultiSelectLineage, MultiSelectLineage)
|
|
1226
1232
|
):
|
|
@@ -1234,7 +1240,7 @@ class Concept(Addressable, DataTyped, ConceptArgs, Mergeable, Namespaced, BaseMo
|
|
|
1234
1240
|
elif (
|
|
1235
1241
|
lineage
|
|
1236
1242
|
and isinstance(lineage, (BuildFunction, Function))
|
|
1237
|
-
and lineage.operator
|
|
1243
|
+
and lineage.operator in FunctionClass.ONE_TO_MANY.value
|
|
1238
1244
|
):
|
|
1239
1245
|
return Derivation.UNNEST
|
|
1240
1246
|
elif (
|
|
@@ -1286,7 +1292,8 @@ class Concept(Addressable, DataTyped, ConceptArgs, Mergeable, Namespaced, BaseMo
|
|
|
1286
1292
|
elif (
|
|
1287
1293
|
lineage
|
|
1288
1294
|
and isinstance(lineage, (Function, BuildFunction))
|
|
1289
|
-
and lineage.operator
|
|
1295
|
+
and lineage.operator
|
|
1296
|
+
in (FunctionType.UNNEST, FunctionType.UNION, FunctionType.DATE_SPINE)
|
|
1290
1297
|
):
|
|
1291
1298
|
return Granularity.MULTI_ROW
|
|
1292
1299
|
elif lineage and all(
|
|
@@ -2132,6 +2139,89 @@ class AlignClause(Namespaced, BaseModel):
|
|
|
2132
2139
|
)
|
|
2133
2140
|
|
|
2134
2141
|
|
|
2142
|
+
class DeriveItem(Namespaced, DataTyped, ConceptArgs, Mergeable, BaseModel):
|
|
2143
|
+
expr: Expr
|
|
2144
|
+
name: str
|
|
2145
|
+
namespace: str
|
|
2146
|
+
|
|
2147
|
+
@property
|
|
2148
|
+
def derived_concept(self) -> str:
|
|
2149
|
+
return f"{self.namespace}.{self.name}"
|
|
2150
|
+
# return ConceptRef(
|
|
2151
|
+
# address=f"{self.namespace}.{self.name}",
|
|
2152
|
+
# datatype=arg_to_datatype(self.expr),
|
|
2153
|
+
# )
|
|
2154
|
+
|
|
2155
|
+
def with_namespace(self, namespace):
|
|
2156
|
+
return DeriveItem.model_construct(
|
|
2157
|
+
expr=(self.expr.with_namespace(namespace) if self.expr else None),
|
|
2158
|
+
name=self.name,
|
|
2159
|
+
namespace=namespace,
|
|
2160
|
+
)
|
|
2161
|
+
|
|
2162
|
+
def with_merge(
|
|
2163
|
+
self, source: Concept, target: Concept, modifiers: List[Modifier]
|
|
2164
|
+
) -> "DeriveItem":
|
|
2165
|
+
return DeriveItem.model_construct(
|
|
2166
|
+
expr=(
|
|
2167
|
+
self.expr.with_merge(source, target, modifiers)
|
|
2168
|
+
if isinstance(self.expr, Mergeable)
|
|
2169
|
+
else self.expr
|
|
2170
|
+
),
|
|
2171
|
+
name=self.name,
|
|
2172
|
+
namespace=self.namespace,
|
|
2173
|
+
)
|
|
2174
|
+
|
|
2175
|
+
def with_reference_replacement(self, source, target):
|
|
2176
|
+
return DeriveItem.model_construct(
|
|
2177
|
+
expr=(
|
|
2178
|
+
self.expr.with_reference_replacement(source, target)
|
|
2179
|
+
if isinstance(self.expr, Mergeable)
|
|
2180
|
+
else self.expr
|
|
2181
|
+
),
|
|
2182
|
+
name=self.name,
|
|
2183
|
+
namespace=self.namespace,
|
|
2184
|
+
)
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
class DeriveClause(Mergeable, Namespaced, BaseModel):
|
|
2188
|
+
items: List[DeriveItem]
|
|
2189
|
+
|
|
2190
|
+
def with_namespace(self, namespace: str) -> "DeriveClause":
|
|
2191
|
+
return DeriveClause.model_construct(
|
|
2192
|
+
items=[
|
|
2193
|
+
x.with_namespace(namespace) if isinstance(x, Namespaced) else x
|
|
2194
|
+
for x in self.items
|
|
2195
|
+
]
|
|
2196
|
+
)
|
|
2197
|
+
|
|
2198
|
+
def with_merge(
|
|
2199
|
+
self, source: Concept, target: Concept, modifiers: List[Modifier]
|
|
2200
|
+
) -> "DeriveClause":
|
|
2201
|
+
return DeriveClause.model_construct(
|
|
2202
|
+
items=[
|
|
2203
|
+
(
|
|
2204
|
+
x.with_merge(source, target, modifiers)
|
|
2205
|
+
if isinstance(x, Mergeable)
|
|
2206
|
+
else x
|
|
2207
|
+
)
|
|
2208
|
+
for x in self.items
|
|
2209
|
+
]
|
|
2210
|
+
)
|
|
2211
|
+
|
|
2212
|
+
def with_reference_replacement(self, source, target):
|
|
2213
|
+
return DeriveClause.model_construct(
|
|
2214
|
+
items=[
|
|
2215
|
+
(
|
|
2216
|
+
x.with_reference_replacement(source, target)
|
|
2217
|
+
if isinstance(x, Mergeable)
|
|
2218
|
+
else x
|
|
2219
|
+
)
|
|
2220
|
+
for x in self.items
|
|
2221
|
+
]
|
|
2222
|
+
)
|
|
2223
|
+
|
|
2224
|
+
|
|
2135
2225
|
class SelectLineage(Mergeable, Namespaced, BaseModel):
|
|
2136
2226
|
selection: List[ConceptRef]
|
|
2137
2227
|
hidden_components: set[str]
|
|
@@ -2176,15 +2266,40 @@ class SelectLineage(Mergeable, Namespaced, BaseModel):
|
|
|
2176
2266
|
),
|
|
2177
2267
|
)
|
|
2178
2268
|
|
|
2269
|
+
def with_namespace(self, namespace):
|
|
2270
|
+
return SelectLineage.model_construct(
|
|
2271
|
+
selection=[x.with_namespace(namespace) for x in self.selection],
|
|
2272
|
+
hidden_components=self.hidden_components,
|
|
2273
|
+
local_concepts={
|
|
2274
|
+
x: y.with_namespace(namespace) for x, y in self.local_concepts.items()
|
|
2275
|
+
},
|
|
2276
|
+
order_by=self.order_by.with_namespace(namespace) if self.order_by else None,
|
|
2277
|
+
limit=self.limit,
|
|
2278
|
+
meta=self.meta,
|
|
2279
|
+
grain=self.grain.with_namespace(namespace),
|
|
2280
|
+
where_clause=(
|
|
2281
|
+
self.where_clause.with_namespace(namespace)
|
|
2282
|
+
if self.where_clause
|
|
2283
|
+
else None
|
|
2284
|
+
),
|
|
2285
|
+
having_clause=(
|
|
2286
|
+
self.having_clause.with_namespace(namespace)
|
|
2287
|
+
if self.having_clause
|
|
2288
|
+
else None
|
|
2289
|
+
),
|
|
2290
|
+
)
|
|
2291
|
+
|
|
2179
2292
|
|
|
2180
2293
|
class MultiSelectLineage(Mergeable, ConceptArgs, Namespaced, BaseModel):
|
|
2181
2294
|
selects: List[SelectLineage]
|
|
2182
2295
|
align: AlignClause
|
|
2296
|
+
|
|
2183
2297
|
namespace: str
|
|
2184
2298
|
order_by: Optional[OrderBy] = None
|
|
2185
2299
|
limit: Optional[int] = None
|
|
2186
2300
|
where_clause: Union["WhereClause", None] = Field(default=None)
|
|
2187
2301
|
having_clause: Union["HavingClause", None] = Field(default=None)
|
|
2302
|
+
derive: DeriveClause | None = None
|
|
2188
2303
|
hidden_components: set[str]
|
|
2189
2304
|
|
|
2190
2305
|
@property
|
|
@@ -2210,6 +2325,11 @@ class MultiSelectLineage(Mergeable, ConceptArgs, Namespaced, BaseModel):
|
|
|
2210
2325
|
new = MultiSelectLineage.model_construct(
|
|
2211
2326
|
selects=[s.with_merge(source, target, modifiers) for s in self.selects],
|
|
2212
2327
|
align=self.align,
|
|
2328
|
+
derive=(
|
|
2329
|
+
self.derive.with_merge(source, target, modifiers)
|
|
2330
|
+
if self.derive
|
|
2331
|
+
else None
|
|
2332
|
+
),
|
|
2213
2333
|
namespace=self.namespace,
|
|
2214
2334
|
hidden_components=self.hidden_components,
|
|
2215
2335
|
order_by=(
|
|
@@ -2235,6 +2355,7 @@ class MultiSelectLineage(Mergeable, ConceptArgs, Namespaced, BaseModel):
|
|
|
2235
2355
|
return MultiSelectLineage.model_construct(
|
|
2236
2356
|
selects=[c.with_namespace(namespace) for c in self.selects],
|
|
2237
2357
|
align=self.align.with_namespace(namespace),
|
|
2358
|
+
derive=self.derive.with_namespace(namespace) if self.derive else None,
|
|
2238
2359
|
namespace=namespace,
|
|
2239
2360
|
hidden_components=self.hidden_components,
|
|
2240
2361
|
order_by=self.order_by.with_namespace(namespace) if self.order_by else None,
|
|
@@ -2256,6 +2377,9 @@ class MultiSelectLineage(Mergeable, ConceptArgs, Namespaced, BaseModel):
|
|
|
2256
2377
|
output = set()
|
|
2257
2378
|
for item in self.align.items:
|
|
2258
2379
|
output.add(item.aligned_concept)
|
|
2380
|
+
if self.derive:
|
|
2381
|
+
for ditem in self.derive.items:
|
|
2382
|
+
output.add(ditem.derived_concept)
|
|
2259
2383
|
return output
|
|
2260
2384
|
|
|
2261
2385
|
@property
|