pytrilogy 0.0.3.76__py3-none-any.whl → 0.0.3.77__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.76.dist-info → pytrilogy-0.0.3.77.dist-info}/METADATA +1 -1
- {pytrilogy-0.0.3.76.dist-info → pytrilogy-0.0.3.77.dist-info}/RECORD +9 -9
- trilogy/__init__.py +1 -1
- trilogy/parsing/parse_engine.py +47 -4
- trilogy/parsing/trilogy.lark +3 -1
- {pytrilogy-0.0.3.76.dist-info → pytrilogy-0.0.3.77.dist-info}/WHEEL +0 -0
- {pytrilogy-0.0.3.76.dist-info → pytrilogy-0.0.3.77.dist-info}/entry_points.txt +0 -0
- {pytrilogy-0.0.3.76.dist-info → pytrilogy-0.0.3.77.dist-info}/licenses/LICENSE.md +0 -0
- {pytrilogy-0.0.3.76.dist-info → pytrilogy-0.0.3.77.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
pytrilogy-0.0.3.
|
|
2
|
-
trilogy/__init__.py,sha256=
|
|
1
|
+
pytrilogy-0.0.3.77.dist-info/licenses/LICENSE.md,sha256=5ZRvtTyCCFwz1THxDTjAu3Lidds9WjPvvzgVwPSYNDo,1042
|
|
2
|
+
trilogy/__init__.py,sha256=MaNvYTE25EzVDkpklTQu2tZ8pSfm2j1aCH9wBRXrMpY,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
|
|
@@ -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=c8NzO4xR3egV-tKS02X6Ja5P4-QfWtnTzkfEn0eKYeU,76660
|
|
101
101
|
trilogy/parsing/render.py,sha256=HSNntD82GiiwHT-TWPLXAaIMWLYVV5B5zQEsgwrHIBE,19605
|
|
102
|
-
trilogy/parsing/trilogy.lark,sha256=
|
|
102
|
+
trilogy/parsing/trilogy.lark,sha256=wiGXJdKfPTG7E_XdkN1rf9g9Yy1-UMVAXyTxtrBPm9w,15037
|
|
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.77.dist-info/METADATA,sha256=LApdnLN-kkLR7hIwuXiUQuAS_cFqfzITIcXqME1p0Jo,9734
|
|
114
|
+
pytrilogy-0.0.3.77.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
115
|
+
pytrilogy-0.0.3.77.dist-info/entry_points.txt,sha256=ewBPU2vLnVexZVnB-NrVj-p3E-4vukg83Zk8A55Wp2w,56
|
|
116
|
+
pytrilogy-0.0.3.77.dist-info/top_level.txt,sha256=cAy__NW_eMAa_yT9UnUNlZLFfxcg6eimUAZ184cdNiE,8
|
|
117
|
+
pytrilogy-0.0.3.77.dist-info/RECORD,,
|
trilogy/__init__.py
CHANGED
trilogy/parsing/parse_engine.py
CHANGED
|
@@ -7,7 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
from re import IGNORECASE
|
|
8
8
|
from typing import Any, List, Optional, Tuple, Union
|
|
9
9
|
|
|
10
|
-
from lark import Lark, ParseTree, Transformer, Tree, v_args
|
|
10
|
+
from lark import Lark, ParseTree, Token, Transformer, Tree, v_args
|
|
11
11
|
from lark.exceptions import (
|
|
12
12
|
UnexpectedCharacters,
|
|
13
13
|
UnexpectedEOF,
|
|
@@ -2091,6 +2091,15 @@ def parse_text_raw(text: str, environment: Optional[Environment] = None):
|
|
|
2091
2091
|
PARSER.parse(text)
|
|
2092
2092
|
|
|
2093
2093
|
|
|
2094
|
+
ERROR_CODES: dict[int, str] = {
|
|
2095
|
+
# 100 code are SQL compatability errors
|
|
2096
|
+
101: "Trilogy does not have a FROM clause (Datasource resolution is automatic). Remove the FROM clause.",
|
|
2097
|
+
# 200 codes relate to required explicit syntax (we could loosen these?)
|
|
2098
|
+
201: 'Alias must be specified with "AS" - e.g. `SELECT x AS y`',
|
|
2099
|
+
210: "Order by must be explicit about direction - specify `asc` or `desc`.",
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
|
|
2094
2103
|
def parse_text(
|
|
2095
2104
|
text: str,
|
|
2096
2105
|
environment: Optional[Environment] = None,
|
|
@@ -2140,9 +2149,43 @@ def parse_text(
|
|
|
2140
2149
|
ValidationError,
|
|
2141
2150
|
TypeError,
|
|
2142
2151
|
) as e:
|
|
2143
|
-
if isinstance(
|
|
2144
|
-
e
|
|
2145
|
-
|
|
2152
|
+
if isinstance(e, UnexpectedToken):
|
|
2153
|
+
if e.expected == {"ORDERING_DIRECTION"}:
|
|
2154
|
+
code = 210
|
|
2155
|
+
raise InvalidSyntaxException(
|
|
2156
|
+
f"Syntax [{code}]:"
|
|
2157
|
+
+ ERROR_CODES[code]
|
|
2158
|
+
+ "\nContext:\n"
|
|
2159
|
+
+ e.get_context(text.replace("\n", " "), 20)
|
|
2160
|
+
)
|
|
2161
|
+
parsed_tokens = (
|
|
2162
|
+
[x.value for x in e.token_history] if e.token_history else []
|
|
2163
|
+
)
|
|
2164
|
+
if parsed_tokens == ["FROM"]:
|
|
2165
|
+
code = 101
|
|
2166
|
+
raise InvalidSyntaxException(
|
|
2167
|
+
f"Syntax [{code}]:"
|
|
2168
|
+
+ ERROR_CODES[code]
|
|
2169
|
+
+ "\nContext:\n"
|
|
2170
|
+
+ e.get_context(text.replace("\n", " "), 20)
|
|
2171
|
+
)
|
|
2172
|
+
# recovery attempt for aliasing
|
|
2173
|
+
try:
|
|
2174
|
+
e.interactive_parser.feed_token(Token("AS", "AS"))
|
|
2175
|
+
e.interactive_parser.feed_token(e.token)
|
|
2176
|
+
raise InvalidSyntaxException(
|
|
2177
|
+
f"Syntax [{ERROR_CODES[201]}]:"
|
|
2178
|
+
+ ERROR_CODES[201]
|
|
2179
|
+
+ "\nContext:\n"
|
|
2180
|
+
+ e.get_context(text.replace("\n", " "), 20)
|
|
2181
|
+
)
|
|
2182
|
+
except UnexpectedToken:
|
|
2183
|
+
pass
|
|
2184
|
+
raise InvalidSyntaxException(
|
|
2185
|
+
str(e) + "\nContext:\n" + e.get_context(text.replace("\n", " "), 20)
|
|
2186
|
+
)
|
|
2187
|
+
elif isinstance(e, (UnexpectedCharacters, UnexpectedEOF, UnexpectedInput)):
|
|
2188
|
+
|
|
2146
2189
|
raise InvalidSyntaxException(
|
|
2147
2190
|
str(e) + "\nContext:\n" + e.get_context(text.replace("\n", " "), 20)
|
|
2148
2191
|
)
|
trilogy/parsing/trilogy.lark
CHANGED
|
@@ -130,7 +130,9 @@
|
|
|
130
130
|
|
|
131
131
|
over_list: concept_lit ("," concept_lit )* ","?
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
ORDERING_DIRECTION: /ASC|DESC/i
|
|
134
|
+
|
|
135
|
+
!ordering: ORDERING_DIRECTION ("NULLS"i /FIRST|LAST|AUTO/i )?
|
|
134
136
|
|
|
135
137
|
order_by: "ORDER"i "BY"i order_list
|
|
136
138
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|