@@ -325,7 +325,7 @@ fn parse_select_count_wildcard() {
325325 assert_eq ! (
326326 & Expr :: Function ( Function {
327327 name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
328- args: vec![ Expr :: Wildcard ] ,
328+ args: vec![ FunctionArg :: Unnamed ( Expr :: Wildcard ) ] ,
329329 over: None ,
330330 distinct: false ,
331331 } ) ,
@@ -340,10 +340,10 @@ fn parse_select_count_distinct() {
340340 assert_eq ! (
341341 & Expr :: Function ( Function {
342342 name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
343- args: vec![ Expr :: UnaryOp {
343+ args: vec![ FunctionArg :: Unnamed ( Expr :: UnaryOp {
344344 op: UnaryOperator :: Plus ,
345345 expr: Box :: new( Expr :: Identifier ( Ident :: new( "x" ) ) )
346- } ] ,
346+ } ) ] ,
347347 over: None ,
348348 distinct: true ,
349349 } ) ,
@@ -883,7 +883,7 @@ fn parse_select_having() {
883883 Some ( Expr :: BinaryOp {
884884 left: Box :: new( Expr :: Function ( Function {
885885 name: ObjectName ( vec![ Ident :: new( "COUNT" ) ] ) ,
886- args: vec![ Expr :: Wildcard ] ,
886+ args: vec![ FunctionArg :: Unnamed ( Expr :: Wildcard ) ] ,
887887 over: None ,
888888 distinct: false
889889 } ) ) ,
@@ -1589,7 +1589,32 @@ fn parse_scalar_function_in_projection() {
15891589 assert_eq ! (
15901590 & Expr :: Function ( Function {
15911591 name: ObjectName ( vec![ Ident :: new( "sqrt" ) ] ) ,
1592- args: vec![ Expr :: Identifier ( Ident :: new( "id" ) ) ] ,
1592+ args: vec![ FunctionArg :: Unnamed ( Expr :: Identifier ( Ident :: new( "id" ) ) ) ] ,
1593+ over: None ,
1594+ distinct: false ,
1595+ } ) ,
1596+ expr_from_projection( only( & select. projection) )
1597+ ) ;
1598+ }
1599+
1600+ #[ test]
1601+ fn parse_named_argument_function ( ) {
1602+ let sql = "SELECT FUN(a => '1', b => '2') FROM foo" ;
1603+ let select = verified_only_select ( sql) ;
1604+
1605+ assert_eq ! (
1606+ & Expr :: Function ( Function {
1607+ name: ObjectName ( vec![ Ident :: new( "FUN" ) ] ) ,
1608+ args: vec![
1609+ FunctionArg :: Named {
1610+ name: Ident :: new( "a" ) ,
1611+ arg: Expr :: Value ( Value :: SingleQuotedString ( "1" . to_owned( ) ) )
1612+ } ,
1613+ FunctionArg :: Named {
1614+ name: Ident :: new( "b" ) ,
1615+ arg: Expr :: Value ( Value :: SingleQuotedString ( "2" . to_owned( ) ) )
1616+ } ,
1617+ ] ,
15931618 over: None ,
15941619 distinct: false ,
15951620 } ) ,
0 commit comments