@ -21,6 +21,7 @@ DESC = keyword("desc")
# SIMPLE KEYWORDS
AS = keyword("as").suppress()
ASSUMING = keyword("assuming")
ALL = keyword("all")
BY = keyword("by").suppress()
CAST = keyword("cast")
@ -162,6 +163,7 @@ RESERVED = MatchFirst([
AND,
AS,
ASC,
ASSUMING,
BETWEEN,
BY,
CASE,
@ -407,9 +407,11 @@ def parser(literal_string, ident, sqlserver=False):
)
+ RB,
assumption = (ASSUMING + (ASC|DESC)("assumption"))
table_source << Group(
((LB + query + RB) | stack | call_function | var_name)("value")
+ Optional(assumption)
+ Optional(flag("with ordinality"))
+ Optional(tablesample)
+ alias
@ -3,4 +3,13 @@ q = 'SELECT p.Name, v.Name FROM Production.Product p JOIN Purchasing.ProductVend
res = parser.parse(q)
print(res)
while True:
try:
q = input()
stmts = parser.parse(q)
for s in stmts:
print(s)
except Exception as e:
print(e)