pytrilogy 0.0.3.74__py3-none-any.whl → 0.0.3.76__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.74.dist-info → pytrilogy-0.0.3.76.dist-info}/METADATA +1 -1
- {pytrilogy-0.0.3.74.dist-info → pytrilogy-0.0.3.76.dist-info}/RECORD +16 -16
- trilogy/__init__.py +1 -1
- trilogy/core/enums.py +1 -1
- trilogy/core/internal.py +20 -2
- trilogy/core/models/author.py +8 -6
- trilogy/core/models/build.py +6 -4
- trilogy/core/statements/execute.py +7 -1
- trilogy/dialect/base.py +48 -13
- trilogy/executor.py +13 -10
- trilogy/parsing/parse_engine.py +13 -4
- trilogy/parsing/trilogy.lark +1 -1
- {pytrilogy-0.0.3.74.dist-info → pytrilogy-0.0.3.76.dist-info}/WHEEL +0 -0
- {pytrilogy-0.0.3.74.dist-info → pytrilogy-0.0.3.76.dist-info}/entry_points.txt +0 -0
- {pytrilogy-0.0.3.74.dist-info → pytrilogy-0.0.3.76.dist-info}/licenses/LICENSE.md +0 -0
- {pytrilogy-0.0.3.74.dist-info → pytrilogy-0.0.3.76.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
pytrilogy-0.0.3.
|
|
2
|
-
trilogy/__init__.py,sha256
|
|
1
|
+
pytrilogy-0.0.3.76.dist-info/licenses/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
|
|
2
|
+
trilogy/__init__.py,sha256=sZwmfj6wT6T8WzjItYxWbPez-bFEh_9z7q4rztVOGdE,303
|
|
3
3
|
trilogy/compiler.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
trilogy/constants.py,sha256=eKb_EJvSqjN9tGbdVEViwdtwwh8fZ3-jpOEDqL71y70,1691
|
|
5
5
|
trilogy/engine.py,sha256=OK2RuqCIUId6yZ5hfF8J1nxGP0AJqHRZiafcowmW0xc,1728
|
|
6
|
-
trilogy/executor.py,sha256=
|
|
6
|
+
trilogy/executor.py,sha256=iwrYs5hEaw2hTaNZOYW5Z0w6Va1RzdRpg5bn50tlslA,16731
|
|
7
7
|
trilogy/parser.py,sha256=o4cfk3j3yhUFoiDKq9ZX_GjBF3dKhDjXEwb63rcBkBM,293
|
|
8
8
|
trilogy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
trilogy/render.py,sha256=qQWwduymauOlB517UtM-VGbVe8Cswa4UJub5aGbSO6c,1512
|
|
@@ -11,20 +11,20 @@ trilogy/utility.py,sha256=euQccZLKoYBz0LNg5tzLlvv2YHvXh9HArnYp1V3uXsM,763
|
|
|
11
11
|
trilogy/authoring/__init__.py,sha256=e74k-Jep4DLYPQU_2m0aVsYlw5HKTOucAKtdTbd6f2g,2595
|
|
12
12
|
trilogy/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
trilogy/core/constants.py,sha256=nizWYDCJQ1bigQMtkNIEMNTcN0NoEAXiIHLzpelxQ24,201
|
|
14
|
-
trilogy/core/enums.py,sha256
|
|
14
|
+
trilogy/core/enums.py,sha256=tDUXVWxvWgnO1u7LLS0iIReeHYbyFLN2ZbpTdUyKdjE,8060
|
|
15
15
|
trilogy/core/env_processor.py,sha256=pFsxnluKIusGKx1z7tTnfsd_xZcPy9pZDungkjkyvI0,3170
|
|
16
16
|
trilogy/core/environment_helpers.py,sha256=VvPIiFemqaLLpIpLIqprfu63K7muZ1YzNg7UZIUph8w,8267
|
|
17
17
|
trilogy/core/ergonomics.py,sha256=e-7gE29vPLFdg0_A1smQ7eOrUwKl5VYdxRSTddHweRA,1631
|
|
18
18
|
trilogy/core/exceptions.py,sha256=jYEduuMehcMkmCpf-OC_taELPZm7qNfeSNzIWkDYScs,707
|
|
19
19
|
trilogy/core/functions.py,sha256=wQ5yCvMKXSCkaSo7yiwlGY0wvqE4Sm2MI9e5NEr2ORw,30933
|
|
20
20
|
trilogy/core/graph_models.py,sha256=BYhJzHKSgnZHVLJs1CfsgrxTPHqKqPNeA64RlozGY0A,3498
|
|
21
|
-
trilogy/core/internal.py,sha256=
|
|
21
|
+
trilogy/core/internal.py,sha256=wFx4e1I0mtx159YFShSXeUBSQ82NINtAbOI-92RX4i8,2151
|
|
22
22
|
trilogy/core/optimization.py,sha256=ojpn-p79lr03SSVQbbw74iPCyoYpDYBmj1dbZ3oXCjI,8860
|
|
23
23
|
trilogy/core/query_processor.py,sha256=5aFgv-2LVM1Uku9cR_tFuTRDwyLnxc95bCMAHeFy2AY,20332
|
|
24
24
|
trilogy/core/utility.py,sha256=3VC13uSQWcZNghgt7Ot0ZTeEmNqs__cx122abVq9qhM,410
|
|
25
25
|
trilogy/core/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
trilogy/core/models/author.py,sha256=
|
|
27
|
-
trilogy/core/models/build.py,sha256=
|
|
26
|
+
trilogy/core/models/author.py,sha256=9gQ2UBJ2qZ4ngFOXei4VbYQAp8UTrcAr_5GvWW2O2l8,78192
|
|
27
|
+
trilogy/core/models/build.py,sha256=0TRcL__hvajLcpFwYeLjCV35cow5oVPbJHXA3oO09XA,65931
|
|
28
28
|
trilogy/core/models/build_environment.py,sha256=s_C9xAHuD3yZ26T15pWVBvoqvlp2LdZ8yjsv2_HdXLk,5363
|
|
29
29
|
trilogy/core/models/core.py,sha256=q-8ExAaSB3PoSDX2XOqfZ01HBBvT1pZFs7jGg1vZizc,11096
|
|
30
30
|
trilogy/core/models/datasource.py,sha256=wogTevZ-9CyUW2a8gjzqMCieircxi-J5lkI7EOAZnck,9596
|
|
@@ -74,9 +74,9 @@ trilogy/core/statements/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
|
74
74
|
trilogy/core/statements/author.py,sha256=6cGCuKERNkH22T6iTsgoNp5CcIFwknF3WX-UmegbUPA,15409
|
|
75
75
|
trilogy/core/statements/build.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
76
76
|
trilogy/core/statements/common.py,sha256=KxEmz2ySySyZ6CTPzn0fJl5NX2KOk1RPyuUSwWhnK1g,759
|
|
77
|
-
trilogy/core/statements/execute.py,sha256=
|
|
77
|
+
trilogy/core/statements/execute.py,sha256=pfr1CZ_Cx1qQ-7LDyRI0JUfvtxBr_GGv-VeqiAjr43g,1406
|
|
78
78
|
trilogy/dialect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
|
-
trilogy/dialect/base.py,sha256=
|
|
79
|
+
trilogy/dialect/base.py,sha256=aLJ7-Lq7TTe7I_FjMzhkC5LfrqyjN55AFD8T0lqsiRs,47202
|
|
80
80
|
trilogy/dialect/bigquery.py,sha256=8xhEu0z_lKANjbvzvBbC7CeKrJf1iP8YyrHqNale-ug,4351
|
|
81
81
|
trilogy/dialect/common.py,sha256=tSthIZOXXRPQ4KeMKnDDsH7KlTmf2EVqigVtLyoc4zc,6071
|
|
82
82
|
trilogy/dialect/config.py,sha256=olnyeVU5W5T6b9-dMeNAnvxuPlyc2uefb7FRME094Ec,3834
|
|
@@ -97,9 +97,9 @@ trilogy/parsing/common.py,sha256=yV1AckK0h8u1OFeGQBTMu-wuW5m63c5CcZuPicsTH_w,306
|
|
|
97
97
|
trilogy/parsing/config.py,sha256=Z-DaefdKhPDmSXLgg5V4pebhSB0h590vI0_VtHnlukI,111
|
|
98
98
|
trilogy/parsing/exceptions.py,sha256=Xwwsv2C9kSNv2q-HrrKC1f60JNHShXcCMzstTSEbiCw,154
|
|
99
99
|
trilogy/parsing/helpers.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
100
|
-
trilogy/parsing/parse_engine.py,sha256=
|
|
100
|
+
trilogy/parsing/parse_engine.py,sha256=4XL-YOEXVZ77w8QKsvWq5gePMo-S-P3vIhhcsywbzNM,74827
|
|
101
101
|
trilogy/parsing/render.py,sha256=HSNntD82GiiwHT-TWPLXAaIMWLYVV5B5zQEsgwrHIBE,19605
|
|
102
|
-
trilogy/parsing/trilogy.lark,sha256=
|
|
102
|
+
trilogy/parsing/trilogy.lark,sha256=v2UqMBhU9hn9km4mvQkk3E2wsEZjJ4cz4wU72NFFvU4,14993
|
|
103
103
|
trilogy/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
104
104
|
trilogy/scripts/trilogy.py,sha256=1L0XrH4mVHRt1C9T1HnaDv2_kYEfbWTb5_-cBBke79w,3774
|
|
105
105
|
trilogy/std/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -110,8 +110,8 @@ trilogy/std/money.preql,sha256=XWwvAV3WxBsHX9zfptoYRnBigcfYwrYtBHXTME0xJuQ,2082
|
|
|
110
110
|
trilogy/std/net.preql,sha256=7l7MqIjs6TDCpO6dBAoNJU81Ex255jZRK36kBgE1GDs,158
|
|
111
111
|
trilogy/std/ranking.preql,sha256=LDoZrYyz4g3xsII9XwXfmstZD-_92i1Eox1UqkBIfi8,83
|
|
112
112
|
trilogy/std/report.preql,sha256=LbV-XlHdfw0jgnQ8pV7acG95xrd1-p65fVpiIc-S7W4,202
|
|
113
|
-
pytrilogy-0.0.3.
|
|
114
|
-
pytrilogy-0.0.3.
|
|
115
|
-
pytrilogy-0.0.3.
|
|
116
|
-
pytrilogy-0.0.3.
|
|
117
|
-
pytrilogy-0.0.3.
|
|
113
|
+
pytrilogy-0.0.3.76.dist-info/METADATA,sha256=NZ4JMPMai3zouER09hbjd6F2cTwSbTqAIzQSR7JmyjM,9734
|
|
114
|
+
pytrilogy-0.0.3.76.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
115
|
+
pytrilogy-0.0.3.76.dist-info/entry_points.txt,sha256=ewBPU2vLnVexZVnB-NrVj-p3E-4vukg83Zk8A55Wp2w,56
|
|
116
|
+
pytrilogy-0.0.3.76.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
|
|
117
|
+
pytrilogy-0.0.3.76.dist-info/RECORD,,
|
trilogy/__init__.py
CHANGED
trilogy/core/enums.py
CHANGED
trilogy/core/internal.py
CHANGED
|
@@ -19,8 +19,26 @@ DEFAULT_CONCEPTS = {
|
|
|
19
19
|
granularity=Granularity.SINGLE_ROW,
|
|
20
20
|
derivation=Derivation.CONSTANT,
|
|
21
21
|
),
|
|
22
|
-
"
|
|
23
|
-
name="
|
|
22
|
+
"concept_address": Concept(
|
|
23
|
+
name="concept_address",
|
|
24
|
+
namespace=INTERNAL_NAMESPACE,
|
|
25
|
+
datatype=DataType.STRING,
|
|
26
|
+
purpose=Purpose.KEY,
|
|
27
|
+
grain=Grain(),
|
|
28
|
+
granularity=Granularity.SINGLE_ROW,
|
|
29
|
+
derivation=Derivation.CONSTANT,
|
|
30
|
+
),
|
|
31
|
+
"concept_datatype": Concept(
|
|
32
|
+
name="concept_datatype",
|
|
33
|
+
namespace=INTERNAL_NAMESPACE,
|
|
34
|
+
datatype=DataType.STRING,
|
|
35
|
+
purpose=Purpose.KEY,
|
|
36
|
+
grain=Grain(),
|
|
37
|
+
granularity=Granularity.SINGLE_ROW,
|
|
38
|
+
derivation=Derivation.CONSTANT,
|
|
39
|
+
),
|
|
40
|
+
"concept_description": Concept(
|
|
41
|
+
name="concept_description",
|
|
24
42
|
namespace=INTERNAL_NAMESPACE,
|
|
25
43
|
datatype=DataType.STRING,
|
|
26
44
|
purpose=Purpose.KEY,
|
trilogy/core/models/author.py
CHANGED
|
@@ -77,7 +77,7 @@ class Mergeable(ABC):
|
|
|
77
77
|
def with_merge(self, source: Concept, target: Concept, modifiers: List[Modifier]):
|
|
78
78
|
raise NotImplementedError
|
|
79
79
|
|
|
80
|
-
def with_reference_replacement(self, source: str, target: Expr):
|
|
80
|
+
def with_reference_replacement(self, source: str, target: Expr | ArgBinding):
|
|
81
81
|
raise NotImplementedError(type(self))
|
|
82
82
|
|
|
83
83
|
|
|
@@ -161,7 +161,7 @@ class ConceptRef(Addressable, Namespaced, DataTyped, Mergeable, BaseModel):
|
|
|
161
161
|
metadata=self.metadata,
|
|
162
162
|
)
|
|
163
163
|
|
|
164
|
-
def with_reference_replacement(self, source: str, target: Expr):
|
|
164
|
+
def with_reference_replacement(self, source: str, target: Expr | ArgBinding):
|
|
165
165
|
if self.address == source:
|
|
166
166
|
return target
|
|
167
167
|
return self
|
|
@@ -1708,7 +1708,7 @@ class Function(DataTyped, ConceptArgs, Mergeable, Namespaced, BaseModel):
|
|
|
1708
1708
|
)
|
|
1709
1709
|
return v
|
|
1710
1710
|
|
|
1711
|
-
def with_reference_replacement(self, source: str, target: Expr):
|
|
1711
|
+
def with_reference_replacement(self, source: str, target: Expr | ArgBinding):
|
|
1712
1712
|
from trilogy.core.functions import arg_to_datatype, merge_datatypes
|
|
1713
1713
|
|
|
1714
1714
|
nargs = [
|
|
@@ -2303,13 +2303,13 @@ class CustomFunctionFactory:
|
|
|
2303
2303
|
]
|
|
2304
2304
|
return self
|
|
2305
2305
|
|
|
2306
|
-
def __call__(self, *creation_args: Expr):
|
|
2306
|
+
def __call__(self, *creation_args: ArgBinding | Expr):
|
|
2307
2307
|
nout = (
|
|
2308
2308
|
self.function.model_copy(deep=True)
|
|
2309
2309
|
if isinstance(self.function, BaseModel)
|
|
2310
2310
|
else self.function
|
|
2311
2311
|
)
|
|
2312
|
-
creation_arg_list: list[Expr] = list(creation_args)
|
|
2312
|
+
creation_arg_list: list[ArgBinding | Expr] = list(creation_args)
|
|
2313
2313
|
if len(creation_args) < len(self.function_arguments):
|
|
2314
2314
|
for binding in self.function_arguments[len(creation_arg_list) :]:
|
|
2315
2315
|
if binding.default is None:
|
|
@@ -2361,7 +2361,9 @@ class Comment(BaseModel):
|
|
|
2361
2361
|
class ArgBinding(Namespaced, DataTyped, BaseModel):
|
|
2362
2362
|
name: str
|
|
2363
2363
|
default: Expr | None = None
|
|
2364
|
-
datatype:
|
|
2364
|
+
datatype: (
|
|
2365
|
+
DataType | MapType | ArrayType | NumericType | StructType | TraitDataType
|
|
2366
|
+
) = DataType.UNKNOWN
|
|
2365
2367
|
|
|
2366
2368
|
def with_namespace(self, namespace):
|
|
2367
2369
|
return ArgBinding(
|
trilogy/core/models/build.py
CHANGED
|
@@ -606,7 +606,6 @@ class BuildComparison(BuildConceptArgs, ConstantInlineable, BaseModel):
|
|
|
606
606
|
int,
|
|
607
607
|
str,
|
|
608
608
|
float,
|
|
609
|
-
list,
|
|
610
609
|
bool,
|
|
611
610
|
datetime,
|
|
612
611
|
date,
|
|
@@ -619,12 +618,13 @@ class BuildComparison(BuildConceptArgs, ConstantInlineable, BaseModel):
|
|
|
619
618
|
MagicConstants,
|
|
620
619
|
BuildWindowItem,
|
|
621
620
|
BuildAggregateWrapper,
|
|
621
|
+
ListWrapper,
|
|
622
|
+
TupleWrapper,
|
|
622
623
|
]
|
|
623
624
|
right: Union[
|
|
624
625
|
int,
|
|
625
626
|
str,
|
|
626
627
|
float,
|
|
627
|
-
list,
|
|
628
628
|
bool,
|
|
629
629
|
date,
|
|
630
630
|
datetime,
|
|
@@ -638,6 +638,7 @@ class BuildComparison(BuildConceptArgs, ConstantInlineable, BaseModel):
|
|
|
638
638
|
BuildWindowItem,
|
|
639
639
|
BuildAggregateWrapper,
|
|
640
640
|
TupleWrapper,
|
|
641
|
+
ListWrapper,
|
|
641
642
|
]
|
|
642
643
|
operator: ComparisonOperator
|
|
643
644
|
|
|
@@ -734,7 +735,6 @@ class BuildSubselectComparison(BuildComparison):
|
|
|
734
735
|
int,
|
|
735
736
|
str,
|
|
736
737
|
float,
|
|
737
|
-
list,
|
|
738
738
|
bool,
|
|
739
739
|
datetime,
|
|
740
740
|
date,
|
|
@@ -747,12 +747,13 @@ class BuildSubselectComparison(BuildComparison):
|
|
|
747
747
|
MagicConstants,
|
|
748
748
|
BuildWindowItem,
|
|
749
749
|
BuildAggregateWrapper,
|
|
750
|
+
ListWrapper,
|
|
751
|
+
TupleWrapper,
|
|
750
752
|
]
|
|
751
753
|
right: Union[
|
|
752
754
|
int,
|
|
753
755
|
str,
|
|
754
756
|
float,
|
|
755
|
-
list,
|
|
756
757
|
bool,
|
|
757
758
|
date,
|
|
758
759
|
datetime,
|
|
@@ -766,6 +767,7 @@ class BuildSubselectComparison(BuildComparison):
|
|
|
766
767
|
BuildWindowItem,
|
|
767
768
|
BuildAggregateWrapper,
|
|
768
769
|
TupleWrapper,
|
|
770
|
+
ListWrapper,
|
|
769
771
|
]
|
|
770
772
|
operator: ComparisonOperator
|
|
771
773
|
|
|
@@ -38,6 +38,12 @@ class ProcessedRawSQLStatement(BaseModel):
|
|
|
38
38
|
text: str
|
|
39
39
|
|
|
40
40
|
|
|
41
|
+
class ProcessedStaticValueOutput(BaseModel):
|
|
42
|
+
values: List[dict]
|
|
43
|
+
|
|
44
|
+
|
|
41
45
|
class ProcessedShowStatement(BaseModel):
|
|
42
46
|
output_columns: List[ConceptRef]
|
|
43
|
-
output_values: List[
|
|
47
|
+
output_values: List[
|
|
48
|
+
Union[BuildConcept, BuildDatasource, ProcessedQuery, ProcessedStaticValueOutput]
|
|
49
|
+
]
|
trilogy/dialect/base.py
CHANGED
|
@@ -16,6 +16,7 @@ from trilogy.core.enums import (
|
|
|
16
16
|
DatePart,
|
|
17
17
|
FunctionType,
|
|
18
18
|
Ordering,
|
|
19
|
+
ShowCategory,
|
|
19
20
|
UnnestMode,
|
|
20
21
|
WindowType,
|
|
21
22
|
)
|
|
@@ -77,6 +78,7 @@ from trilogy.core.statements.execute import (
|
|
|
77
78
|
ProcessedQueryPersist,
|
|
78
79
|
ProcessedRawSQLStatement,
|
|
79
80
|
ProcessedShowStatement,
|
|
81
|
+
ProcessedStaticValueOutput,
|
|
80
82
|
)
|
|
81
83
|
from trilogy.core.utility import safe_quote
|
|
82
84
|
from trilogy.dialect.common import render_join, render_unnest
|
|
@@ -638,18 +640,7 @@ class BaseDialect:
|
|
|
638
640
|
):
|
|
639
641
|
return f"{self.render_expr(e.left, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)} {e.operator.value} {self.render_expr(e.right, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)}"
|
|
640
642
|
|
|
641
|
-
|
|
642
|
-
e.right,
|
|
643
|
-
(
|
|
644
|
-
str,
|
|
645
|
-
int,
|
|
646
|
-
bool,
|
|
647
|
-
float,
|
|
648
|
-
),
|
|
649
|
-
):
|
|
650
|
-
return f"{self.render_expr(e.left, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)} {e.operator.value} ({self.render_expr(e.right, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)})"
|
|
651
|
-
else:
|
|
652
|
-
return f"{self.render_expr(e.left, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)} {e.operator.value} {self.render_expr(e.right, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)}"
|
|
643
|
+
return f"{self.render_expr(e.left, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)} {e.operator.value} ({self.render_expr(e.right, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)})"
|
|
653
644
|
elif isinstance(e, COMPARISON_ITEMS):
|
|
654
645
|
return f"{self.render_expr(e.left, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)} {e.operator.value} {self.render_expr(e.right, cte=cte, cte_map=cte_map, raise_invalid=raise_invalid)}"
|
|
655
646
|
elif isinstance(e, CONDITIONAL_ITEMS):
|
|
@@ -953,6 +944,46 @@ class BaseDialect:
|
|
|
953
944
|
self.render_cte(sort_select_output(query.ctes[-1], query), auto_sort=False)
|
|
954
945
|
]
|
|
955
946
|
|
|
947
|
+
def create_show_output(
|
|
948
|
+
self,
|
|
949
|
+
environment: Environment,
|
|
950
|
+
content: ShowCategory,
|
|
951
|
+
):
|
|
952
|
+
if content == ShowCategory.CONCEPTS:
|
|
953
|
+
output_columns = [
|
|
954
|
+
environment.concepts[
|
|
955
|
+
DEFAULT_CONCEPTS["concept_address"].address
|
|
956
|
+
].reference,
|
|
957
|
+
environment.concepts[
|
|
958
|
+
DEFAULT_CONCEPTS["concept_datatype"].address
|
|
959
|
+
].reference,
|
|
960
|
+
environment.concepts[
|
|
961
|
+
DEFAULT_CONCEPTS["concept_description"].address
|
|
962
|
+
].reference,
|
|
963
|
+
]
|
|
964
|
+
output_values = [
|
|
965
|
+
{
|
|
966
|
+
DEFAULT_CONCEPTS["concept_address"].address: (
|
|
967
|
+
concept.name
|
|
968
|
+
if concept.namespace == DEFAULT_NAMESPACE
|
|
969
|
+
else concept.address
|
|
970
|
+
),
|
|
971
|
+
DEFAULT_CONCEPTS["concept_datatype"].address: str(concept.datatype),
|
|
972
|
+
DEFAULT_CONCEPTS[
|
|
973
|
+
"concept_description"
|
|
974
|
+
].address: concept.metadata.description
|
|
975
|
+
or "",
|
|
976
|
+
}
|
|
977
|
+
for _, concept in environment.concepts.items()
|
|
978
|
+
if not concept.is_internal
|
|
979
|
+
]
|
|
980
|
+
else:
|
|
981
|
+
raise NotImplementedError(f"Show category {content} not implemented")
|
|
982
|
+
return ProcessedShowStatement(
|
|
983
|
+
output_columns=output_columns,
|
|
984
|
+
output_values=[ProcessedStaticValueOutput(values=output_values)],
|
|
985
|
+
)
|
|
986
|
+
|
|
956
987
|
def generate_queries(
|
|
957
988
|
self,
|
|
958
989
|
environment: Environment,
|
|
@@ -1027,8 +1058,12 @@ class BaseDialect:
|
|
|
1027
1058
|
],
|
|
1028
1059
|
)
|
|
1029
1060
|
)
|
|
1061
|
+
elif isinstance(statement.content, ShowCategory):
|
|
1062
|
+
output.append(
|
|
1063
|
+
self.create_show_output(environment, statement.content)
|
|
1064
|
+
)
|
|
1030
1065
|
else:
|
|
1031
|
-
raise NotImplementedError(type(statement))
|
|
1066
|
+
raise NotImplementedError(type(statement.content))
|
|
1032
1067
|
elif isinstance(statement, RawSQLStatement):
|
|
1033
1068
|
output.append(ProcessedRawSQLStatement(text=statement.text))
|
|
1034
1069
|
elif isinstance(
|
trilogy/executor.py
CHANGED
|
@@ -30,6 +30,7 @@ from trilogy.core.statements.execute import (
|
|
|
30
30
|
ProcessedQueryPersist,
|
|
31
31
|
ProcessedRawSQLStatement,
|
|
32
32
|
ProcessedShowStatement,
|
|
33
|
+
ProcessedStaticValueOutput,
|
|
33
34
|
)
|
|
34
35
|
from trilogy.dialect.base import BaseDialect
|
|
35
36
|
from trilogy.dialect.enums import Dialects
|
|
@@ -470,16 +471,18 @@ class Executor(object):
|
|
|
470
471
|
# connection = self.engine.connect()
|
|
471
472
|
for statement in self.parse_text_generator(command):
|
|
472
473
|
if isinstance(statement, ProcessedShowStatement):
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
474
|
+
for x in statement.output_values:
|
|
475
|
+
if isinstance(x, ProcessedStaticValueOutput):
|
|
476
|
+
output.append(
|
|
477
|
+
generate_result_set(statement.output_columns, x.values)
|
|
478
|
+
)
|
|
479
|
+
elif isinstance(x, ProcessedQuery):
|
|
480
|
+
output.append(
|
|
481
|
+
generate_result_set(
|
|
482
|
+
statement.output_columns,
|
|
483
|
+
[self.generator.compile_statement(x)],
|
|
484
|
+
)
|
|
485
|
+
)
|
|
483
486
|
continue
|
|
484
487
|
if non_interactive:
|
|
485
488
|
if not isinstance(
|
trilogy/parsing/parse_engine.py
CHANGED
|
@@ -524,8 +524,12 @@ class ParseToObjects(Transformer):
|
|
|
524
524
|
@v_args(meta=True)
|
|
525
525
|
def column_assignment(self, meta: Meta, args):
|
|
526
526
|
modifiers = []
|
|
527
|
-
|
|
528
|
-
|
|
527
|
+
if len(args) == 2:
|
|
528
|
+
alias = args[0]
|
|
529
|
+
concept_list = args[1]
|
|
530
|
+
else:
|
|
531
|
+
alias = args[0][-1]
|
|
532
|
+
concept_list = args[0]
|
|
529
533
|
# recursively collect modifiers
|
|
530
534
|
if len(concept_list) > 1:
|
|
531
535
|
modifiers += concept_list[:-1]
|
|
@@ -2030,12 +2034,17 @@ class ParseToObjects(Transformer):
|
|
|
2030
2034
|
return self.environment.functions[args[0]]
|
|
2031
2035
|
|
|
2032
2036
|
@v_args(meta=True)
|
|
2033
|
-
def farray_transform(self, meta, args):
|
|
2037
|
+
def farray_transform(self, meta, args) -> Function:
|
|
2034
2038
|
factory: CustomFunctionFactory = args[1]
|
|
2035
2039
|
if not len(factory.function_arguments) == 1:
|
|
2036
2040
|
raise InvalidSyntaxException(
|
|
2037
2041
|
"Array transform function must have exactly one argument;"
|
|
2038
2042
|
)
|
|
2043
|
+
array_type = arg_to_datatype(args[0])
|
|
2044
|
+
if not isinstance(array_type, ArrayType):
|
|
2045
|
+
raise InvalidSyntaxException(
|
|
2046
|
+
f"Array transform function must be applied to an array, not {array_type}"
|
|
2047
|
+
)
|
|
2039
2048
|
return self.function_factory.create_function(
|
|
2040
2049
|
[
|
|
2041
2050
|
args[0],
|
|
@@ -2043,7 +2052,7 @@ class ParseToObjects(Transformer):
|
|
|
2043
2052
|
factory(
|
|
2044
2053
|
ArgBinding(
|
|
2045
2054
|
name=factory.function_arguments[0].name,
|
|
2046
|
-
datatype=
|
|
2055
|
+
datatype=array_type.value_data_type,
|
|
2047
2056
|
)
|
|
2048
2057
|
),
|
|
2049
2058
|
],
|
trilogy/parsing/trilogy.lark
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
|
|
52
52
|
//column_assignment
|
|
53
53
|
//figure out if we want static
|
|
54
|
-
column_assignment: (raw_column_assignment | IDENTIFIER | QUOTED_IDENTIFIER | expr ) ":" concept_assignment
|
|
54
|
+
column_assignment: ((raw_column_assignment | IDENTIFIER | QUOTED_IDENTIFIER | expr ) ":" concept_assignment) | concept_assignment
|
|
55
55
|
|
|
56
56
|
RAW_ENTRY.1: /raw\s*\(/s
|
|
57
57
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|