@@ -502,12 +502,6 @@ impl AggregateFunctionDefinition {
502
502
AggregateFunctionDefinition :: Name ( func_name) => func_name. as_ref ( ) ,
503
503
}
504
504
}
505
-
506
- pub fn new_builtin (
507
- fun : aggregate_function:: AggregateFunction ,
508
- ) -> AggregateFunctionDefinition {
509
- Self :: BuiltIn ( fun)
510
- }
511
505
}
512
506
513
507
/// Aggregate function
@@ -534,7 +528,7 @@ impl AggregateFunction {
534
528
order_by : Option < Vec < Expr > > ,
535
529
) -> Self {
536
530
Self {
537
- func_def : AggregateFunctionDefinition :: new_builtin ( fun) ,
531
+ func_def : AggregateFunctionDefinition :: BuiltIn ( fun) ,
538
532
args,
539
533
distinct,
540
534
filter,
@@ -1611,7 +1605,7 @@ fn create_name(e: &Expr) -> Result<String> {
1611
1605
filter,
1612
1606
order_by,
1613
1607
} ) => {
1614
- let mut name = match func_def {
1608
+ let name = match func_def {
1615
1609
AggregateFunctionDefinition :: BuiltIn ( ..)
1616
1610
| AggregateFunctionDefinition :: Name ( ..) => {
1617
1611
create_function_name ( func_def. name ( ) , * distinct, args) ?
@@ -1624,13 +1618,21 @@ fn create_name(e: &Expr) -> Result<String> {
1624
1618
names. join ( "," )
1625
1619
}
1626
1620
} ;
1621
+ let mut info = String :: new ( ) ;
1627
1622
if let Some ( fe) = filter {
1628
- name = format ! ( "{name} FILTER (WHERE {fe})" ) ;
1623
+ info += & format ! ( " FILTER (WHERE {fe})" ) ;
1629
1624
} ;
1630
1625
if let Some ( order_by) = order_by {
1631
- name = format ! ( "{name} ORDER BY [{}]" , expr_vec_fmt!( order_by) ) ;
1626
+ info += & format ! ( "{name} ORDER BY [{}]" , expr_vec_fmt!( order_by) ) ;
1632
1627
} ;
1633
- Ok ( name)
1628
+
1629
+ match func_def {
1630
+ AggregateFunctionDefinition :: BuiltIn ( ..)
1631
+ | AggregateFunctionDefinition :: Name ( ..) => Ok ( name) ,
1632
+ AggregateFunctionDefinition :: UDF ( ..) => {
1633
+ Ok ( format ! ( "{}({}){}" , func_def. name( ) , name, info) )
1634
+ }
1635
+ }
1634
1636
}
1635
1637
Expr :: GroupingSet ( grouping_set) => match grouping_set {
1636
1638
GroupingSet :: Rollup ( exprs) => {
0 commit comments