pytrilogy 0.0.3.0__py3-none-any.whl → 0.0.3.1__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.0.dist-info → pytrilogy-0.0.3.1.dist-info}/METADATA +1 -1
- {pytrilogy-0.0.3.0.dist-info → pytrilogy-0.0.3.1.dist-info}/RECORD +18 -18
- trilogy/__init__.py +1 -1
- trilogy/core/models/build.py +41 -27
- trilogy/core/models/environment.py +5 -0
- trilogy/core/processing/concept_strategies_v3.py +0 -2
- trilogy/core/processing/node_generators/rowset_node.py +4 -6
- trilogy/core/processing/node_generators/window_node.py +0 -1
- trilogy/core/query_processor.py +6 -1
- trilogy/dialect/base.py +3 -1
- trilogy/hooks/__init__.py +4 -0
- trilogy/hooks/query_debugger.py +4 -5
- trilogy/parsing/common.py +9 -5
- trilogy/parsing/parse_engine.py +15 -2
- {pytrilogy-0.0.3.0.dist-info → pytrilogy-0.0.3.1.dist-info}/LICENSE.md +0 -0
- {pytrilogy-0.0.3.0.dist-info → pytrilogy-0.0.3.1.dist-info}/WHEEL +0 -0
- {pytrilogy-0.0.3.0.dist-info → pytrilogy-0.0.3.1.dist-info}/entry_points.txt +0 -0
- {pytrilogy-0.0.3.0.dist-info → pytrilogy-0.0.3.1.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
trilogy/__init__.py,sha256=
|
|
1
|
+
trilogy/__init__.py,sha256=KLYdc650VOIzjRZdH4baZEtSeBPReI5LTzjij3xENfE,302
|
|
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
|
|
@@ -17,14 +17,14 @@ trilogy/core/functions.py,sha256=7Pq9jYSJd45L2pxT7AI-_rXVZmeLnmTPp8d1lA4z4Vk,244
|
|
|
17
17
|
trilogy/core/graph_models.py,sha256=z17EoO8oky2QOuO6E2aMWoVNKEVJFhLdsQZOhC4fNLU,2079
|
|
18
18
|
trilogy/core/internal.py,sha256=iicDBlC6nM8d7e7jqzf_ZOmpUsW8yrr2AA8AqEiLx-s,1577
|
|
19
19
|
trilogy/core/optimization.py,sha256=xGO8piVsLrpqrx-Aid_Y56_5slSv4eZmlP64hCHRiEc,7957
|
|
20
|
-
trilogy/core/query_processor.py,sha256=
|
|
20
|
+
trilogy/core/query_processor.py,sha256=HyDxBhQsD9KX-Y7pYznlpCAW6AvI76RqPTQNa1mreoE,19450
|
|
21
21
|
trilogy/core/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
trilogy/core/models/author.py,sha256=Ai-AFBsr4sbm3T0WE3TxFwB73foGg7-uKUTyQtoBEXQ,67093
|
|
23
|
-
trilogy/core/models/build.py,sha256=
|
|
23
|
+
trilogy/core/models/build.py,sha256=kiq31T8LtUtgmT37m617Q2MlMvQTuAxJzwb6947EiWU,56127
|
|
24
24
|
trilogy/core/models/build_environment.py,sha256=8UggvlPU708GZWYPJMc_ou2r7M3TY2g69eqGvz03YX0,5528
|
|
25
25
|
trilogy/core/models/core.py,sha256=yie1uuq62uOQ5fjob9NMJbdvQPrCErXUT7JTCuYRyjI,9697
|
|
26
26
|
trilogy/core/models/datasource.py,sha256=c0tGxyH2WwTmAD047tr69U0a6GNVf-ug26H68yii7DA,9257
|
|
27
|
-
trilogy/core/models/environment.py,sha256=
|
|
27
|
+
trilogy/core/models/environment.py,sha256=QSl-H6nwarzKbQgNRjtwDKMJtA4F_GVQpRs-NMNt-6Q,24983
|
|
28
28
|
trilogy/core/models/execute.py,sha256=ABylFQgtavjjCfFkEsFdUwfMB4UBQLHjdzQ9E67QlAE,33521
|
|
29
29
|
trilogy/core/optimizations/__init__.py,sha256=EBanqTXEzf1ZEYjAneIWoIcxtMDite5-n2dQ5xcfUtg,356
|
|
30
30
|
trilogy/core/optimizations/base_optimization.py,sha256=gzDOKImoFn36k7XBD3ysEYDnbnb6vdVIztUfFQZsGnM,513
|
|
@@ -32,7 +32,7 @@ trilogy/core/optimizations/inline_constant.py,sha256=lvNTIXaLNkw3HseJyXyDNk5R52d
|
|
|
32
32
|
trilogy/core/optimizations/inline_datasource.py,sha256=AHuTGh2x0GQ8usOe0NiFncfTFQ_KogdgDl4uucmhIbI,4241
|
|
33
33
|
trilogy/core/optimizations/predicate_pushdown.py,sha256=g4AYE8Aw_iMlAh68TjNXGP754NTurrDduFECkUjoBnc,9399
|
|
34
34
|
trilogy/core/processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
-
trilogy/core/processing/concept_strategies_v3.py,sha256=
|
|
35
|
+
trilogy/core/processing/concept_strategies_v3.py,sha256=hzClGgWxfqxnx4Nc0iIr_DwOybAnuk5RozCijqsZUg4,39168
|
|
36
36
|
trilogy/core/processing/graph_utils.py,sha256=8QUVrkE9j-9C1AyrCb1nQEh8daCe0u1HuXl-Te85lag,1205
|
|
37
37
|
trilogy/core/processing/utility.py,sha256=Oc5tLGeDDpzhbfo2ZcF8ex1kez-NcJDMcG2Lm5BjS4c,20548
|
|
38
38
|
trilogy/core/processing/node_generators/__init__.py,sha256=s_YV1OYc336DuS9591259qjI_K_CtOCuhkf4t2aOgYs,733
|
|
@@ -43,12 +43,12 @@ trilogy/core/processing/node_generators/group_node.py,sha256=94uoGZWvBKJ1eqjbDHC
|
|
|
43
43
|
trilogy/core/processing/node_generators/group_to_node.py,sha256=E5bEjovSx422d_MlAUCDFdY4P2WJVp61BmWwltkhzA8,3095
|
|
44
44
|
trilogy/core/processing/node_generators/multiselect_node.py,sha256=z9FQOxxUvxW31a0TckFfAvnuvU8vP1GyN224RTbXUAk,7114
|
|
45
45
|
trilogy/core/processing/node_generators/node_merge_node.py,sha256=sv55oynfqgpHEpo1OEtVDri-5fywzPhDlR85qaWikvY,16195
|
|
46
|
-
trilogy/core/processing/node_generators/rowset_node.py,sha256=
|
|
46
|
+
trilogy/core/processing/node_generators/rowset_node.py,sha256=lVjwxO71HVZ5De82bo7YYILVQ7cYeXdCzIloLCfpyLE,6112
|
|
47
47
|
trilogy/core/processing/node_generators/select_merge_node.py,sha256=VHCPMbnKfg7AOfoYa6PKxpNni-j5JEfliNUiltmZhds,19698
|
|
48
48
|
trilogy/core/processing/node_generators/select_node.py,sha256=Y-zO0AFkTrpi2LyebjpyHU7WWANr7nKZSS9rY7DH4Wo,1888
|
|
49
49
|
trilogy/core/processing/node_generators/union_node.py,sha256=zuMSmgF170vzlp2BBQEhKbqUMjVl2xQDqUB82Dhv-VU,2536
|
|
50
50
|
trilogy/core/processing/node_generators/unnest_node.py,sha256=cOEKnMRzXUW3bwmiOlgn3E1-B38osng0dh2pDykwITY,2410
|
|
51
|
-
trilogy/core/processing/node_generators/window_node.py,sha256=
|
|
51
|
+
trilogy/core/processing/node_generators/window_node.py,sha256=6KoxhmpVOTN3HGWT0FIS96xqlm2Inouw9VL2D_0kSg0,3481
|
|
52
52
|
trilogy/core/processing/node_generators/select_helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
trilogy/core/processing/node_generators/select_helpers/datasource_injection.py,sha256=GMW07bb6hXurhF0hZLYoMAKSIS65tat5hwBjvqqPeSA,6516
|
|
54
54
|
trilogy/core/processing/nodes/__init__.py,sha256=DqPG3Y8vl5-UTeox6hn1EE6iwPIJpsM-XeZALHSgLZQ,5058
|
|
@@ -66,7 +66,7 @@ trilogy/core/statements/build.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
|
66
66
|
trilogy/core/statements/common.py,sha256=KxEmz2ySySyZ6CTPzn0fJl5NX2KOk1RPyuUSwWhnK1g,759
|
|
67
67
|
trilogy/core/statements/execute.py,sha256=cSlvpHFOqpiZ89pPZ5GDp9Hu6j6uj-5_h21FWm_L-KM,1248
|
|
68
68
|
trilogy/dialect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
69
|
-
trilogy/dialect/base.py,sha256=
|
|
69
|
+
trilogy/dialect/base.py,sha256=H6eebtFV09edKbBpukxxB0xBftolXFhvXbshbZhNeUI,40290
|
|
70
70
|
trilogy/dialect/bigquery.py,sha256=mKC3zoEU232h9RtIXJjqiZ72lWH8a6S28p6wAZKrAfg,2952
|
|
71
71
|
trilogy/dialect/common.py,sha256=cbTo_vamdp8pj9spSjGSH-bSZpy4FpNJ12k5vMvyT2Y,3942
|
|
72
72
|
trilogy/dialect/config.py,sha256=UiBY2tBbNk9owx-zxP_3lN9lErEUXhXIU_bcXA18AvU,2992
|
|
@@ -76,24 +76,24 @@ trilogy/dialect/postgres.py,sha256=VH4EB4myjIeZTHeFU6vK00GxY9c53rCBjg2mLbdaCEE,3
|
|
|
76
76
|
trilogy/dialect/presto.py,sha256=bAxaDcLL21fivPg7hmBd3HJmd0yYJdPdwNgNA5ga7DE,3391
|
|
77
77
|
trilogy/dialect/snowflake.py,sha256=wmao9p26jX5yIX5SC8sRAZTXkPGTvq6ixO693QTfhz8,2989
|
|
78
78
|
trilogy/dialect/sql_server.py,sha256=IN91uEM0MpsiVAlsYC89uMQkiVn0i86B8Tst6v9uFkU,3129
|
|
79
|
-
trilogy/hooks/__init__.py,sha256=
|
|
79
|
+
trilogy/hooks/__init__.py,sha256=T3SF3phuUDPLXKGRVE_Lf9mzuwoXWyaLolncR_1kY30,144
|
|
80
80
|
trilogy/hooks/base_hook.py,sha256=I_l-NBMNC7hKTDx1JgHZPVOOCvLQ36m2oIGaR5EUMXY,1180
|
|
81
81
|
trilogy/hooks/graph_hook.py,sha256=c-vC-IXoJ_jDmKQjxQyIxyXPOuUcLIURB573gCsAfzQ,2940
|
|
82
|
-
trilogy/hooks/query_debugger.py,sha256=
|
|
82
|
+
trilogy/hooks/query_debugger.py,sha256=1npRjww94sPV5RRBBlLqMJRaFkH9vhEY6o828MeoEcw,5583
|
|
83
83
|
trilogy/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
84
84
|
trilogy/parsing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
85
|
-
trilogy/parsing/common.py,sha256=
|
|
85
|
+
trilogy/parsing/common.py,sha256=b_TGP-cSV21Y8INI77DhD3c4kg0vpJ5TZUuzU-JcdaU,20594
|
|
86
86
|
trilogy/parsing/config.py,sha256=Z-DaefdKhPDmSXLgg5V4pebhSB0h590vI0_VtHnlukI,111
|
|
87
87
|
trilogy/parsing/exceptions.py,sha256=92E5i2frv5hj9wxObJZsZqj5T6bglvPzvdvco_vW1Zk,38
|
|
88
88
|
trilogy/parsing/helpers.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
89
|
-
trilogy/parsing/parse_engine.py,sha256=
|
|
89
|
+
trilogy/parsing/parse_engine.py,sha256=rtlwl-WzcPCd5pm0WhXHwe8JGOJCuQm_EAnRj6qG93w,54318
|
|
90
90
|
trilogy/parsing/render.py,sha256=o_XuQWhcwx1lD9eGVqkqZEwkmQK0HdmWWokGBtdeH4I,17837
|
|
91
91
|
trilogy/parsing/trilogy.lark,sha256=EazfEvYPuvkPkNjUnVzFi0uD9baavugbSI8CyfawShk,12573
|
|
92
92
|
trilogy/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
93
93
|
trilogy/scripts/trilogy.py,sha256=1L0XrH4mVHRt1C9T1HnaDv2_kYEfbWTb5_-cBBke79w,3774
|
|
94
|
-
pytrilogy-0.0.3.
|
|
95
|
-
pytrilogy-0.0.3.
|
|
96
|
-
pytrilogy-0.0.3.
|
|
97
|
-
pytrilogy-0.0.3.
|
|
98
|
-
pytrilogy-0.0.3.
|
|
99
|
-
pytrilogy-0.0.3.
|
|
94
|
+
pytrilogy-0.0.3.1.dist-info/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
|
|
95
|
+
pytrilogy-0.0.3.1.dist-info/METADATA,sha256=HAkTZhYCZL5M6_WSWKakxXEHP5xqxSMMgKhM2E6HndE,8983
|
|
96
|
+
pytrilogy-0.0.3.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
97
|
+
pytrilogy-0.0.3.1.dist-info/entry_points.txt,sha256=0petKryjvvtEfTlbZC1AuMFumH_WQ9v8A19LvoS6G6c,54
|
|
98
|
+
pytrilogy-0.0.3.1.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
|
|
99
|
+
pytrilogy-0.0.3.1.dist-info/RECORD,,
|
trilogy/__init__.py
CHANGED
trilogy/core/models/build.py
CHANGED
|
@@ -242,6 +242,9 @@ class BuildGrain(BaseModel):
|
|
|
242
242
|
components: set[str] = Field(default_factory=set)
|
|
243
243
|
where_clause: Optional[BuildWhereClause] = None
|
|
244
244
|
|
|
245
|
+
def __init__(self, **kwargs):
|
|
246
|
+
super().__init__(**kwargs)
|
|
247
|
+
|
|
245
248
|
def without_condition(self):
|
|
246
249
|
return BuildGrain(components=self.components)
|
|
247
250
|
|
|
@@ -1171,7 +1174,7 @@ class BuildFilterItem(BuildConceptArgs, BaseModel):
|
|
|
1171
1174
|
|
|
1172
1175
|
class BuildRowsetLineage(BuildConceptArgs, BaseModel):
|
|
1173
1176
|
name: str
|
|
1174
|
-
derived_concepts: List[
|
|
1177
|
+
derived_concepts: List[str]
|
|
1175
1178
|
select: SelectLineage | MultiSelectLineage
|
|
1176
1179
|
|
|
1177
1180
|
|
|
@@ -1222,8 +1225,8 @@ class BuildSelectLineage(BaseModel):
|
|
|
1222
1225
|
limit: Optional[int] = None
|
|
1223
1226
|
meta: Metadata = Field(default_factory=lambda: Metadata())
|
|
1224
1227
|
grain: BuildGrain = Field(default_factory=BuildGrain)
|
|
1225
|
-
where_clause:
|
|
1226
|
-
having_clause:
|
|
1228
|
+
where_clause: BuildWhereClause | None = Field(default=None)
|
|
1229
|
+
having_clause: BuildHavingClause | None = Field(default=None)
|
|
1227
1230
|
|
|
1228
1231
|
@property
|
|
1229
1232
|
def output_components(self) -> List[BuildConcept]:
|
|
@@ -1447,7 +1450,9 @@ class Factory:
|
|
|
1447
1450
|
):
|
|
1448
1451
|
self.grain = grain or Grain()
|
|
1449
1452
|
self.environment = environment
|
|
1450
|
-
self.local_concepts: dict[str, BuildConcept] =
|
|
1453
|
+
self.local_concepts: dict[str, BuildConcept] = (
|
|
1454
|
+
{} if local_concepts is None else local_concepts
|
|
1455
|
+
)
|
|
1451
1456
|
|
|
1452
1457
|
@singledispatchmethod
|
|
1453
1458
|
def build(self, base):
|
|
@@ -1494,7 +1499,7 @@ class Factory:
|
|
|
1494
1499
|
@build.register
|
|
1495
1500
|
def _(self, base: Function) -> BuildFunction:
|
|
1496
1501
|
|
|
1497
|
-
new = BuildFunction(
|
|
1502
|
+
new = BuildFunction.model_construct(
|
|
1498
1503
|
operator=base.operator,
|
|
1499
1504
|
arguments=[self.build(c) for c in base.arguments],
|
|
1500
1505
|
output_datatype=base.output_datatype,
|
|
@@ -1515,14 +1520,14 @@ class Factory:
|
|
|
1515
1520
|
|
|
1516
1521
|
@build.register
|
|
1517
1522
|
def _(self, base: CaseWhen) -> BuildCaseWhen:
|
|
1518
|
-
return BuildCaseWhen(
|
|
1523
|
+
return BuildCaseWhen.model_construct(
|
|
1519
1524
|
comparison=self.build(base.comparison),
|
|
1520
1525
|
expr=(self.build(base.expr)),
|
|
1521
1526
|
)
|
|
1522
1527
|
|
|
1523
1528
|
@build.register
|
|
1524
1529
|
def _(self, base: CaseElse) -> BuildCaseElse:
|
|
1525
|
-
return BuildCaseElse(expr=self.build(base.expr))
|
|
1530
|
+
return BuildCaseElse.model_construct(expr=self.build(base.expr))
|
|
1526
1531
|
|
|
1527
1532
|
@build.register
|
|
1528
1533
|
def _(self, base: Concept) -> BuildConcept:
|
|
@@ -1537,7 +1542,7 @@ class Factory:
|
|
|
1537
1542
|
derivation, final_grain, build_lineage
|
|
1538
1543
|
)
|
|
1539
1544
|
is_aggregate = Concept.calculate_is_aggregate(build_lineage)
|
|
1540
|
-
rval = BuildConcept(
|
|
1545
|
+
rval = BuildConcept.model_construct(
|
|
1541
1546
|
name=base.name,
|
|
1542
1547
|
datatype=base.datatype,
|
|
1543
1548
|
purpose=base.purpose,
|
|
@@ -1565,12 +1570,12 @@ class Factory:
|
|
|
1565
1570
|
else:
|
|
1566
1571
|
by = [self.build(x) for x in base.by]
|
|
1567
1572
|
parent = self.build(base.function)
|
|
1568
|
-
return BuildAggregateWrapper(function=parent, by=by)
|
|
1573
|
+
return BuildAggregateWrapper.model_construct(function=parent, by=by)
|
|
1569
1574
|
|
|
1570
1575
|
@build.register
|
|
1571
1576
|
def _(self, base: ColumnAssignment) -> BuildColumnAssignment:
|
|
1572
1577
|
|
|
1573
|
-
return BuildColumnAssignment(
|
|
1578
|
+
return BuildColumnAssignment.model_construct(
|
|
1574
1579
|
alias=(
|
|
1575
1580
|
self.build(base.alias)
|
|
1576
1581
|
if isinstance(base.alias, Function)
|
|
@@ -1584,26 +1589,31 @@ class Factory:
|
|
|
1584
1589
|
|
|
1585
1590
|
@build.register
|
|
1586
1591
|
def _(self, base: OrderBy) -> BuildOrderBy:
|
|
1587
|
-
return BuildOrderBy(items=[self.build(x) for x in base.items])
|
|
1592
|
+
return BuildOrderBy.model_construct(items=[self.build(x) for x in base.items])
|
|
1588
1593
|
|
|
1589
1594
|
@build.register
|
|
1590
1595
|
def _(self, base: OrderItem) -> BuildOrderItem:
|
|
1591
|
-
return BuildOrderItem(
|
|
1596
|
+
return BuildOrderItem.model_construct(
|
|
1592
1597
|
expr=(self.build(base.expr)),
|
|
1593
1598
|
order=base.order,
|
|
1594
1599
|
)
|
|
1595
1600
|
|
|
1596
1601
|
@build.register
|
|
1597
1602
|
def _(self, base: WhereClause) -> BuildWhereClause:
|
|
1598
|
-
return BuildWhereClause
|
|
1603
|
+
return BuildWhereClause.model_construct(
|
|
1604
|
+
conditional=self.build(base.conditional)
|
|
1605
|
+
)
|
|
1599
1606
|
|
|
1600
1607
|
@build.register
|
|
1601
1608
|
def _(self, base: HavingClause) -> BuildHavingClause:
|
|
1602
|
-
return BuildHavingClause
|
|
1609
|
+
return BuildHavingClause.model_construct(
|
|
1610
|
+
conditional=self.build(base.conditional)
|
|
1611
|
+
)
|
|
1603
1612
|
|
|
1604
1613
|
@build.register
|
|
1605
1614
|
def _(self, base: WindowItem) -> BuildWindowItem:
|
|
1606
|
-
|
|
1615
|
+
|
|
1616
|
+
return BuildWindowItem.model_construct(
|
|
1607
1617
|
type=base.type,
|
|
1608
1618
|
content=self.build(base.content),
|
|
1609
1619
|
order_by=[self.build(x) for x in base.order_by],
|
|
@@ -1613,7 +1623,7 @@ class Factory:
|
|
|
1613
1623
|
|
|
1614
1624
|
@build.register
|
|
1615
1625
|
def _(self, base: Conditional) -> BuildConditional:
|
|
1616
|
-
return BuildConditional(
|
|
1626
|
+
return BuildConditional.model_construct(
|
|
1617
1627
|
left=(self.build(base.left)),
|
|
1618
1628
|
right=(self.build(base.right)),
|
|
1619
1629
|
operator=base.operator,
|
|
@@ -1621,7 +1631,7 @@ class Factory:
|
|
|
1621
1631
|
|
|
1622
1632
|
@build.register
|
|
1623
1633
|
def _(self, base: SubselectComparison) -> BuildSubselectComparison:
|
|
1624
|
-
return BuildSubselectComparison(
|
|
1634
|
+
return BuildSubselectComparison.model_construct(
|
|
1625
1635
|
left=(self.build(base.left)),
|
|
1626
1636
|
right=(self.build(base.right)),
|
|
1627
1637
|
operator=base.operator,
|
|
@@ -1629,7 +1639,7 @@ class Factory:
|
|
|
1629
1639
|
|
|
1630
1640
|
@build.register
|
|
1631
1641
|
def _(self, base: Comparison) -> BuildComparison:
|
|
1632
|
-
return BuildComparison(
|
|
1642
|
+
return BuildComparison.model_construct(
|
|
1633
1643
|
left=(self.build(base.left)),
|
|
1634
1644
|
right=(self.build(base.right)),
|
|
1635
1645
|
operator=base.operator,
|
|
@@ -1637,7 +1647,7 @@ class Factory:
|
|
|
1637
1647
|
|
|
1638
1648
|
@build.register
|
|
1639
1649
|
def _(self, base: AlignItem) -> BuildAlignItem:
|
|
1640
|
-
return BuildAlignItem(
|
|
1650
|
+
return BuildAlignItem.model_construct(
|
|
1641
1651
|
alias=base.alias,
|
|
1642
1652
|
concepts=[self.build(x) for x in base.concepts],
|
|
1643
1653
|
namespace=base.namespace,
|
|
@@ -1645,7 +1655,9 @@ class Factory:
|
|
|
1645
1655
|
|
|
1646
1656
|
@build.register
|
|
1647
1657
|
def _(self, base: AlignClause) -> BuildAlignClause:
|
|
1648
|
-
return BuildAlignClause
|
|
1658
|
+
return BuildAlignClause.model_construct(
|
|
1659
|
+
items=[self.build(x) for x in base.items]
|
|
1660
|
+
)
|
|
1649
1661
|
|
|
1650
1662
|
@build.register
|
|
1651
1663
|
def _(self, base: RowsetItem):
|
|
@@ -1663,7 +1675,7 @@ class Factory:
|
|
|
1663
1675
|
def _(self, base: RowsetLineage) -> BuildRowsetLineage:
|
|
1664
1676
|
out = BuildRowsetLineage(
|
|
1665
1677
|
name=base.name,
|
|
1666
|
-
derived_concepts=[],
|
|
1678
|
+
derived_concepts=[x.address for x in base.derived_concepts],
|
|
1667
1679
|
select=base.select,
|
|
1668
1680
|
)
|
|
1669
1681
|
return out
|
|
@@ -1675,17 +1687,19 @@ class Factory:
|
|
|
1675
1687
|
where = factory.build(base.where_clause)
|
|
1676
1688
|
else:
|
|
1677
1689
|
where = None
|
|
1678
|
-
return BuildGrain(
|
|
1690
|
+
return BuildGrain.model_construct(
|
|
1691
|
+
components=base.components, where_clause=where
|
|
1692
|
+
)
|
|
1679
1693
|
|
|
1680
1694
|
@build.register
|
|
1681
1695
|
def _(self, base: FilterItem) -> BuildFilterItem:
|
|
1682
|
-
return BuildFilterItem(
|
|
1696
|
+
return BuildFilterItem.model_construct(
|
|
1683
1697
|
content=self.build(base.content), where=self.build(base.where)
|
|
1684
1698
|
)
|
|
1685
1699
|
|
|
1686
1700
|
@build.register
|
|
1687
1701
|
def _(self, base: Parenthetical) -> BuildParenthetical:
|
|
1688
|
-
return BuildParenthetical(content=(self.build(base.content)))
|
|
1702
|
+
return BuildParenthetical.model_construct(content=(self.build(base.content)))
|
|
1689
1703
|
|
|
1690
1704
|
@build.register
|
|
1691
1705
|
def _(self, base: SelectLineage) -> BuildSelectLineage:
|
|
@@ -1753,7 +1767,7 @@ class Factory:
|
|
|
1753
1767
|
derived_base = []
|
|
1754
1768
|
for k in base.derived_concepts:
|
|
1755
1769
|
base_concept = self.environment.concepts[k]
|
|
1756
|
-
x = BuildConcept(
|
|
1770
|
+
x = BuildConcept.model_construct(
|
|
1757
1771
|
name=base_concept.name,
|
|
1758
1772
|
datatype=base_concept.datatype,
|
|
1759
1773
|
purpose=base_concept.purpose,
|
|
@@ -1778,7 +1792,7 @@ class Factory:
|
|
|
1778
1792
|
local_concepts=local_build_cache,
|
|
1779
1793
|
)
|
|
1780
1794
|
where_factory = Factory(environment=self.environment)
|
|
1781
|
-
lineage = BuildMultiSelectLineage(
|
|
1795
|
+
lineage = BuildMultiSelectLineage.model_construct(
|
|
1782
1796
|
# we don't build selects here; they'll be built automatically in query discovery
|
|
1783
1797
|
selects=base.selects,
|
|
1784
1798
|
grain=final_grain,
|
|
@@ -1831,7 +1845,7 @@ class Factory:
|
|
|
1831
1845
|
factory = Factory(
|
|
1832
1846
|
grain=base.grain, environment=self.environment, local_concepts=local_cache
|
|
1833
1847
|
)
|
|
1834
|
-
return BuildDatasource(
|
|
1848
|
+
return BuildDatasource.model_construct(
|
|
1835
1849
|
name=base.name,
|
|
1836
1850
|
columns=[factory.build(c) for c in base.columns],
|
|
1837
1851
|
address=base.address,
|
|
@@ -39,6 +39,7 @@ from trilogy.core.models.author import (
|
|
|
39
39
|
Concept,
|
|
40
40
|
ConceptRef,
|
|
41
41
|
Function,
|
|
42
|
+
SelectLineage,
|
|
42
43
|
UndefinedConcept,
|
|
43
44
|
UndefinedConceptFull,
|
|
44
45
|
address_with_namespace,
|
|
@@ -189,6 +190,7 @@ class Environment(BaseModel):
|
|
|
189
190
|
] = Field(default_factory=EnvironmentDatasourceDict)
|
|
190
191
|
functions: Dict[str, Function] = Field(default_factory=dict)
|
|
191
192
|
data_types: Dict[str, DataType] = Field(default_factory=dict)
|
|
193
|
+
named_statements: Dict[str, SelectLineage] = Field(default_factory=dict)
|
|
192
194
|
imports: Dict[str, list[Import]] = Field(
|
|
193
195
|
default_factory=lambda: defaultdict(list) # type: ignore
|
|
194
196
|
)
|
|
@@ -217,6 +219,9 @@ class Environment(BaseModel):
|
|
|
217
219
|
|
|
218
220
|
return Factory(self, local_concepts=local_concepts).build(self)
|
|
219
221
|
|
|
222
|
+
def add_rowset(self, name: str, lineage: SelectLineage):
|
|
223
|
+
self.named_statements[name] = lineage
|
|
224
|
+
|
|
220
225
|
def duplicate(self):
|
|
221
226
|
return Environment.model_construct(
|
|
222
227
|
datasources=self.datasources.duplicate(),
|
|
@@ -54,17 +54,15 @@ def gen_rowset_node(
|
|
|
54
54
|
rowset_relevant: list[BuildConcept] = [
|
|
55
55
|
v
|
|
56
56
|
for v in environment.concepts.values()
|
|
57
|
-
if
|
|
58
|
-
and v.lineage.rowset.name == rowset.name
|
|
57
|
+
if v.address in lineage.rowset.derived_concepts
|
|
59
58
|
]
|
|
60
|
-
|
|
61
|
-
# f"{padding(depth)}{LOGGER_PREFIX} rowset relevant nodes are {rowset_relevant}"
|
|
62
|
-
# )
|
|
59
|
+
|
|
63
60
|
select_hidden = node.hidden_concepts
|
|
64
61
|
rowset_hidden = [
|
|
65
62
|
x
|
|
66
63
|
for x in rowset_relevant
|
|
67
|
-
if
|
|
64
|
+
if x.address in lineage.rowset.derived_concepts
|
|
65
|
+
and isinstance(x.lineage, BuildRowsetItem)
|
|
68
66
|
and x.lineage.content.address in select_hidden
|
|
69
67
|
]
|
|
70
68
|
additional_relevant = [
|
trilogy/core/query_processor.py
CHANGED
|
@@ -12,6 +12,8 @@ from trilogy.core.models.build import (
|
|
|
12
12
|
BuildConcept,
|
|
13
13
|
BuildConditional,
|
|
14
14
|
BuildDatasource,
|
|
15
|
+
BuildMultiSelectLineage,
|
|
16
|
+
BuildSelectLineage,
|
|
15
17
|
Factory,
|
|
16
18
|
)
|
|
17
19
|
from trilogy.core.models.environment import Environment
|
|
@@ -373,7 +375,10 @@ def get_query_node(
|
|
|
373
375
|
raise ValueError(f"Statement has no output components {statement}")
|
|
374
376
|
|
|
375
377
|
history = history or History(base_environment=environment)
|
|
376
|
-
build_statement = Factory(
|
|
378
|
+
build_statement: BuildSelectLineage | BuildMultiSelectLineage = Factory(
|
|
379
|
+
environment=environment
|
|
380
|
+
).build(statement)
|
|
381
|
+
|
|
377
382
|
# build_statement = statement
|
|
378
383
|
build_environment = environment.materialize_for_select(
|
|
379
384
|
build_statement.local_concepts
|
trilogy/dialect/base.py
CHANGED
|
@@ -84,7 +84,9 @@ CONDITIONAL_ITEMS = (BuildConditional,)
|
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
def INVALID_REFERENCE_STRING(x: Any, callsite: str = ""):
|
|
87
|
-
#
|
|
87
|
+
# if CONFIG.validate_missing:
|
|
88
|
+
# raise SyntaxError(f"INVALID_REFERENCE_BUG_{callsite}<{x}>")
|
|
89
|
+
|
|
88
90
|
return f"INVALID_REFERENCE_BUG_{callsite}<{x}>"
|
|
89
91
|
|
|
90
92
|
|
trilogy/hooks/__init__.py
CHANGED
trilogy/hooks/query_debugger.py
CHANGED
|
@@ -12,7 +12,6 @@ from trilogy.core.models.execute import (
|
|
|
12
12
|
)
|
|
13
13
|
from trilogy.core.processing.nodes import StrategyNode
|
|
14
14
|
from trilogy.core.statements.author import SelectStatement
|
|
15
|
-
from trilogy.dialect.bigquery import BigqueryDialect
|
|
16
15
|
from trilogy.hooks.base_hook import BaseHook
|
|
17
16
|
|
|
18
17
|
|
|
@@ -22,9 +21,6 @@ class PrintMode(Enum):
|
|
|
22
21
|
FULL = 3
|
|
23
22
|
|
|
24
23
|
|
|
25
|
-
renderer = BigqueryDialect()
|
|
26
|
-
|
|
27
|
-
|
|
28
24
|
class DebuggingHook(BaseHook):
|
|
29
25
|
def __init__(
|
|
30
26
|
self,
|
|
@@ -46,6 +42,9 @@ class DebuggingHook(BaseHook):
|
|
|
46
42
|
self.process_other = PrintMode(process_other)
|
|
47
43
|
self.messages: list[str] = []
|
|
48
44
|
self.uuid = uuid4()
|
|
45
|
+
from trilogy.dialect.bigquery import BigqueryDialect
|
|
46
|
+
|
|
47
|
+
self.renderer = BigqueryDialect()
|
|
49
48
|
|
|
50
49
|
def print(self, *args):
|
|
51
50
|
merged = " ".join([str(x) for x in args])
|
|
@@ -123,7 +122,7 @@ class DebuggingHook(BaseHook):
|
|
|
123
122
|
self.print(
|
|
124
123
|
" " * depth, input.name, "->", input.group_to_grain, "->", select_statement
|
|
125
124
|
)
|
|
126
|
-
sql = renderer.render_cte(input).statement
|
|
125
|
+
sql = self.renderer.render_cte(input).statement
|
|
127
126
|
for line in sql.split("\n"):
|
|
128
127
|
logger.debug(" " * (depth) + line)
|
|
129
128
|
if isinstance(input, CTE):
|
trilogy/parsing/common.py
CHANGED
|
@@ -503,6 +503,11 @@ def rowset_to_concepts(rowset: RowsetDerivationStatement, environment: Environme
|
|
|
503
503
|
if isinstance(orig_concept.lineage, FilterItem):
|
|
504
504
|
if orig_concept.lineage.where == rowset.select.where_clause:
|
|
505
505
|
name = environment.concepts[orig_concept.lineage.content.address].name
|
|
506
|
+
base_namespace = (
|
|
507
|
+
f"{rowset.name}.{orig_concept.namespace}"
|
|
508
|
+
if orig_concept.namespace != rowset.namespace
|
|
509
|
+
else rowset.name
|
|
510
|
+
)
|
|
506
511
|
|
|
507
512
|
new_concept = Concept(
|
|
508
513
|
name=name,
|
|
@@ -512,11 +517,7 @@ def rowset_to_concepts(rowset: RowsetDerivationStatement, environment: Environme
|
|
|
512
517
|
grain=orig_concept.grain,
|
|
513
518
|
# TODO: add proper metadata
|
|
514
519
|
metadata=Metadata(concept_source=ConceptSource.CTE),
|
|
515
|
-
namespace=
|
|
516
|
-
f"{rowset.name}.{orig_concept.namespace}"
|
|
517
|
-
if orig_concept.namespace != rowset.namespace
|
|
518
|
-
else rowset.name
|
|
519
|
-
),
|
|
520
|
+
namespace=base_namespace,
|
|
520
521
|
keys=orig_concept.keys,
|
|
521
522
|
derivation=Derivation.ROWSET,
|
|
522
523
|
granularity=orig_concept.granularity,
|
|
@@ -538,6 +539,9 @@ def rowset_to_concepts(rowset: RowsetDerivationStatement, environment: Environme
|
|
|
538
539
|
default_grain = Grain.from_concepts([*pre_output])
|
|
539
540
|
# remap everything to the properties of the rowset
|
|
540
541
|
for x in pre_output:
|
|
542
|
+
print("xxxx")
|
|
543
|
+
print(x.address)
|
|
544
|
+
print(x.grain)
|
|
541
545
|
if x.keys:
|
|
542
546
|
if all([k in orig for k in x.keys]):
|
|
543
547
|
x.keys = set([orig[k].address if k in orig else k for k in x.keys])
|
trilogy/parsing/parse_engine.py
CHANGED
|
@@ -576,11 +576,24 @@ class ParseToObjects(Transformer):
|
|
|
576
576
|
select=select,
|
|
577
577
|
namespace=self.environment.namespace or DEFAULT_NAMESPACE,
|
|
578
578
|
)
|
|
579
|
+
|
|
580
|
+
# clean up current definitions
|
|
581
|
+
# to_delete = set()
|
|
582
|
+
# if output.name in self.environment.named_statements:
|
|
583
|
+
# for k, v in self.environment.concepts.items():
|
|
584
|
+
# if v.derivation == Derivation.ROWSET and v.lineage.rowset.name == name:
|
|
585
|
+
# to_delete.add(k)
|
|
586
|
+
# for k in to_delete:
|
|
587
|
+
# self.environment.concepts.pop(k)
|
|
588
|
+
|
|
579
589
|
for new_concept in rowset_to_concepts(output, self.environment):
|
|
580
590
|
if new_concept.metadata:
|
|
581
591
|
new_concept.metadata.line_number = meta.line
|
|
582
|
-
|
|
583
|
-
|
|
592
|
+
self.environment.add_concept(new_concept, force=True)
|
|
593
|
+
|
|
594
|
+
self.environment.add_rowset(
|
|
595
|
+
output.name, output.select.as_lineage(self.environment)
|
|
596
|
+
)
|
|
584
597
|
return output
|
|
585
598
|
|
|
586
599
|
@v_args(meta=True)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|