@@ -348,6 +348,8 @@ pub enum Expr {
348348ListAgg ( ListAgg ) , 
349349    /// The `ARRAY_AGG` function `SELECT ARRAY_AGG(... ORDER BY ...)` 
350350ArrayAgg ( ArrayAgg ) , 
351+     /// The `WITHIN GROUP` expr `... WITHIN GROUP (ORDER BY ...)` 
352+ WithinGroup ( WithinGroup ) , 
351353    /// The `GROUPING SETS` expr. 
352354GroupingSets ( Vec < Vec < Expr > > ) , 
353355    /// The `CUBE` expr. 
@@ -549,6 +551,7 @@ impl fmt::Display for Expr {
549551            Expr :: ArraySubquery ( s)  => write ! ( f,  "ARRAY({})" ,  s) , 
550552            Expr :: ListAgg ( listagg)  => write ! ( f,  "{}" ,  listagg) , 
551553            Expr :: ArrayAgg ( arrayagg)  => write ! ( f,  "{}" ,  arrayagg) , 
554+             Expr :: WithinGroup ( withingroup)  => write ! ( f,  "{}" ,  withingroup) , 
552555            Expr :: GroupingSets ( sets)  => { 
553556                write ! ( f,  "GROUPING SETS (" ) ?; 
554557                let  mut  sep = "" ; 
@@ -2523,6 +2526,26 @@ impl fmt::Display for ArrayAgg {
25232526    } 
25242527} 
25252528
2529+ /// A `WITHIN GROUP` invocation `<expr> WITHIN GROUP (ORDER BY <sort_expr> )` 
2530+ #[ derive( Debug ,  Clone ,  PartialEq ,  Eq ,  Hash ) ]  
2531+ #[ cfg_attr( feature = "serde" ,  derive( Serialize ,  Deserialize ) ) ]  
2532+ pub  struct  WithinGroup  { 
2533+     pub  expr :  Box < Expr > , 
2534+     pub  order_by :  Vec < OrderByExpr > , 
2535+ } 
2536+ 
2537+ impl  fmt:: Display  for  WithinGroup  { 
2538+     fn  fmt ( & self ,  f :  & mut  fmt:: Formatter )  -> fmt:: Result  { 
2539+         write ! ( 
2540+             f, 
2541+             "{} WITHIN GROUP (ORDER BY {})" , 
2542+             self . expr, 
2543+             display_comma_separated( & self . order_by) , 
2544+         ) ?; 
2545+         Ok ( ( ) ) 
2546+     } 
2547+ } 
2548+ 
25262549#[ derive( Debug ,  Clone ,  PartialEq ,  Eq ,  Hash ) ]  
25272550#[ cfg_attr( feature = "serde" ,  derive( Serialize ,  Deserialize ) ) ]  
25282551pub  enum  ObjectType  { 
0 commit comments