@@ -883,29 +883,8 @@ impl<'a> Parser<'a> {
883
883
let args = self . parse_optional_args ( ) ?;
884
884
let over = if self . parse_keyword ( Keyword :: OVER ) {
885
885
if self . consume_token ( & Token :: LParen ) {
886
- let partition_by = if self . parse_keywords ( & [ Keyword :: PARTITION , Keyword :: BY ] ) {
887
- self . parse_comma_separated ( Parser :: parse_expr) ?
888
- } else {
889
- vec ! [ ]
890
- } ;
891
- let order_by = if self . parse_keywords ( & [ Keyword :: ORDER , Keyword :: BY ] ) {
892
- self . parse_comma_separated ( Parser :: parse_order_by_expr) ?
893
- } else {
894
- vec ! [ ]
895
- } ;
896
- let window_frame = if !self . consume_token ( & Token :: RParen ) {
897
- let window_frame = self . parse_window_frame ( ) ?;
898
- self . expect_token ( & Token :: RParen ) ?;
899
- Some ( window_frame)
900
- } else {
901
- None
902
- } ;
903
-
904
- Some ( WindowType :: WindowSpec ( WindowSpec {
905
- partition_by,
906
- order_by,
907
- window_frame,
908
- } ) )
886
+ let window_spec = self . parse_window_args ( ) ?;
887
+ Some ( WindowType :: WindowSpec ( window_spec) )
909
888
} else {
910
889
Some ( WindowType :: NamedWindow ( self . parse_identifier ( ) ?) )
911
890
}
@@ -6948,6 +6927,11 @@ impl<'a> Parser<'a> {
6948
6927
let ident = self . parse_identifier ( ) ?;
6949
6928
self . expect_keyword ( Keyword :: AS ) ?;
6950
6929
self . expect_token ( & Token :: LParen ) ?;
6930
+ let window_spec = self . parse_window_args ( ) ?;
6931
+ Ok ( IdentWindow ( ident, window_spec) )
6932
+ }
6933
+
6934
+ pub fn parse_window_args ( & mut self ) -> Result < WindowSpec , ParserError > {
6951
6935
let partition_by = if self . parse_keywords ( & [ Keyword :: PARTITION , Keyword :: BY ] ) {
6952
6936
self . parse_comma_separated ( Parser :: parse_expr) ?
6953
6937
} else {
@@ -6965,12 +6949,11 @@ impl<'a> Parser<'a> {
6965
6949
} else {
6966
6950
None
6967
6951
} ;
6968
- let over = WindowSpec {
6952
+ Ok ( WindowSpec {
6969
6953
partition_by,
6970
6954
order_by,
6971
6955
window_frame,
6972
- } ;
6973
- Ok ( IdentWindow ( ident, over) )
6956
+ } )
6974
6957
}
6975
6958
}
6976
6959
0 commit comments