@@ -44,6 +44,7 @@ use crate::{
4444 datasource:: { provider_as_source, MemTable , TableProvider , ViewTable } ,
4545 error:: { DataFusionError , Result } ,
4646 execution:: { options:: ArrowReadOptions , runtime_env:: RuntimeEnv , FunctionRegistry } ,
47+ logical_expr:: AggregateUDF ,
4748 logical_expr:: {
4849 CreateCatalog , CreateCatalogSchema , CreateExternalTable , CreateFunction ,
4950 CreateMemoryTable , CreateView , DropCatalogSchema , DropFunction , DropTable ,
@@ -53,10 +54,11 @@ use crate::{
5354 optimizer:: analyzer:: { Analyzer , AnalyzerRule } ,
5455 optimizer:: optimizer:: { Optimizer , OptimizerConfig , OptimizerRule } ,
5556 physical_optimizer:: optimizer:: { PhysicalOptimizer , PhysicalOptimizerRule } ,
56- physical_plan:: { udaf :: AggregateUDF , udf:: ScalarUDF , ExecutionPlan } ,
57+ physical_plan:: { udf:: ScalarUDF , ExecutionPlan } ,
5758 physical_planner:: { DefaultPhysicalPlanner , PhysicalPlanner } ,
5859 variable:: { VarProvider , VarType } ,
5960} ;
61+ use crate :: { functions, functions_aggregate, functions_array} ;
6062
6163use arrow:: datatypes:: { DataType , SchemaRef } ;
6264use arrow:: record_batch:: RecordBatch ;
@@ -69,14 +71,11 @@ use datafusion_common::{
6971 SchemaReference , TableReference ,
7072} ;
7173use datafusion_execution:: registry:: SerializerRegistry ;
72- use datafusion_expr:: type_coercion:: aggregates:: NUMERICS ;
73- use datafusion_expr:: { create_first_value, Signature , Volatility } ;
7474use datafusion_expr:: {
7575 logical_plan:: { DdlStatement , Statement } ,
7676 var_provider:: is_system_variables,
7777 Expr , StringifiedPlan , UserDefinedLogicalNode , WindowUDF ,
7878} ;
79- use datafusion_physical_expr:: create_first_value_accumulator;
8079use datafusion_sql:: {
8180 parser:: { CopyToSource , CopyToStatement , DFParser } ,
8281 planner:: { object_name_to_table_reference, ContextProvider , ParserOptions , SqlToRel } ,
@@ -85,7 +84,6 @@ use datafusion_sql::{
8584
8685use async_trait:: async_trait;
8786use chrono:: { DateTime , Utc } ;
88- use log:: debug;
8987use parking_lot:: RwLock ;
9088use sqlparser:: dialect:: dialect_from_str;
9189use url:: Url ;
@@ -1452,29 +1450,16 @@ impl SessionState {
14521450 } ;
14531451
14541452 // register built in functions
1455- datafusion_functions :: register_all ( & mut new_self)
1453+ functions :: register_all ( & mut new_self)
14561454 . expect ( "can not register built in functions" ) ;
14571455
14581456 // register crate of array expressions (if enabled)
14591457 #[ cfg( feature = "array_expressions" ) ]
1460- datafusion_functions_array :: register_all ( & mut new_self)
1458+ functions_array :: register_all ( & mut new_self)
14611459 . expect ( "can not register array expressions" ) ;
14621460
1463- let first_value = create_first_value (
1464- "FIRST_VALUE" ,
1465- Signature :: uniform ( 1 , NUMERICS . to_vec ( ) , Volatility :: Immutable ) ,
1466- Arc :: new ( create_first_value_accumulator) ,
1467- ) ;
1468-
1469- match new_self. register_udaf ( Arc :: new ( first_value) ) {
1470- Ok ( Some ( existing_udaf) ) => {
1471- debug ! ( "Overwrite existing UDAF: {}" , existing_udaf. name( ) ) ;
1472- }
1473- Ok ( None ) => { }
1474- Err ( err) => {
1475- panic ! ( "Failed to register UDAF: {}" , err) ;
1476- }
1477- }
1461+ functions_aggregate:: register_all ( & mut new_self)
1462+ . expect ( "can not register aggregate functions" ) ;
14781463
14791464 new_self
14801465 }
0 commit comments