File tree Expand file tree Collapse file tree 6 files changed +24
-4
lines changed
Expand file tree Collapse file tree 6 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ class Parser(parser.Parser):
128128
129129 NO_PAREN_FUNCTION_PARSERS = {
130130 ** parser .Parser .NO_PAREN_FUNCTION_PARSERS ,
131+ "NEXT" : lambda self : self ._parse_next_value_for (),
131132 "SYSDATE" : lambda self : self .expression (exp .CurrentTimestamp , sysdate = True ),
132133 }
133134
Original file line number Diff line number Diff line change @@ -597,6 +597,11 @@ class Parser(parser.Parser):
597597 ),
598598 }
599599
600+ NO_PAREN_FUNCTION_PARSERS = {
601+ ** parser .Parser .NO_PAREN_FUNCTION_PARSERS ,
602+ "NEXT" : lambda self : self ._parse_next_value_for (),
603+ }
604+
600605 # The DCOLON (::) operator serves as a scope resolution (exp.ScopeResolution) operator in T-SQL
601606 COLUMN_OPERATORS = {
602607 ** parser .Parser .COLUMN_OPERATORS ,
Original file line number Diff line number Diff line change @@ -586,6 +586,7 @@ class Parser(metaclass=_Parser):
586586 TokenType .INSERT ,
587587 TokenType .LIKE ,
588588 TokenType .MERGE ,
589+ TokenType .NEXT ,
589590 TokenType .OFFSET ,
590591 TokenType .PRIMARY_KEY ,
591592 TokenType .RANGE ,
@@ -1107,7 +1108,6 @@ class Parser(metaclass=_Parser):
11071108 exp .ConnectByRoot , this = self ._parse_column ()
11081109 ),
11091110 "IF" : lambda self : self ._parse_if (),
1110- "NEXT" : lambda self : self ._parse_next_value_for (),
11111111 }
11121112
11131113 INVALID_FUNC_NAME_TOKENS = {
Original file line number Diff line number Diff line change @@ -1203,7 +1203,8 @@ def test_match_recognize(self):
12031203 DEFINE
12041204 B AS totalprice < PREV(totalprice),
12051205 C AS totalprice > PREV(totalprice) AND totalprice <= A.totalprice,
1206- D AS totalprice > PREV(totalprice)
1206+ D AS totalprice > PREV(totalprice),
1207+ E AS MAX(foo) >= NEXT(bar)
12071208)""" ,
12081209 pretty = True ,
12091210 )
Original file line number Diff line number Diff line change @@ -2075,3 +2075,18 @@ def test_parsename(self):
20752075 "tsql" : UnsupportedError ,
20762076 },
20772077 )
2078+
2079+ def test_next_value_for (self ):
2080+ self .validate_identity (
2081+ "SELECT NEXT VALUE FOR db.schema.sequence_name OVER (ORDER BY foo), col"
2082+ )
2083+ self .validate_all (
2084+ "SELECT NEXT VALUE FOR db.schema.sequence_name" ,
2085+ read = {
2086+ "oracle" : "SELECT NEXT VALUE FOR db.schema.sequence_name" ,
2087+ "tsql" : "SELECT NEXT VALUE FOR db.schema.sequence_name" ,
2088+ },
2089+ write = {
2090+ "oracle" : "SELECT NEXT VALUE FOR db.schema.sequence_name" ,
2091+ },
2092+ )
Original file line number Diff line number Diff line change @@ -830,8 +830,6 @@ JSON_OBJECT('x': 1 RETURNING VARCHAR(100))
830830JSON_OBJECT(' x' : 1 RETURNING VARBINARY FORMAT JSON ENCODING UTF8)
831831PRIOR AS x
832832SELECT if .x
833- SELECT NEXT VALUE FOR db .schema .sequence_name
834- SELECT NEXT VALUE FOR db .schema .sequence_name OVER (ORDER BY foo), col
835833SELECT PERCENTILE_CONT(x, 0 .5 ) OVER ()
836834WITH my_cte AS (SELECT ' a' AS desc ) SELECT desc AS description FROM my_cte
837835WITH my_cte AS (SELECT ' a' AS asc ) SELECT asc AS description FROM my_cte
You can’t perform that action at this time.
0 commit comments