diff --git a/mo_sql_parsing/keywords.py b/mo_sql_parsing/keywords.py index 3626698..28b2d28 100644 --- a/mo_sql_parsing/keywords.py +++ b/mo_sql_parsing/keywords.py @@ -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, diff --git a/mo_sql_parsing/sql_parser.py b/mo_sql_parsing/sql_parser.py index 499e56b..710d6b2 100644 --- a/mo_sql_parsing/sql_parser.py +++ b/mo_sql_parsing/sql_parser.py @@ -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 diff --git a/run.py b/run.py index 3da498c..45d8da4 100644 --- a/run.py +++ b/run.py @@ -3,4 +3,13 @@ q = 'SELECT p.Name, v.Name FROM Production.Product p JOIN Purchasing.ProductVend res = parser.parse(q) -print(res) \ No newline at end of file +print(res) + +while True: + try: + q = input() + stmts = parser.parse(q) + for s in stmts: + print(s) + except Exception as e: + print(e)