@@ -1467,6 +1467,11 @@ impl SessionContext {
14671467 dropped |= self . state . write ( ) . deregister_udaf ( & stmt. name ) ?. is_some ( ) ;
14681468 dropped |= self . state . write ( ) . deregister_udwf ( & stmt. name ) ?. is_some ( ) ;
14691469 dropped |= self . state . write ( ) . deregister_udtf ( & stmt. name ) ?. is_some ( ) ;
1470+ dropped |= self
1471+ . state
1472+ . write ( )
1473+ . deregister_higher_order_function ( & stmt. name ) ?
1474+ . is_some ( ) ;
14701475
14711476 // DROP FUNCTION IF EXISTS drops the specified function only if that
14721477 // function exists and in this way, it avoids error. While the DROP FUNCTION
@@ -1566,6 +1571,20 @@ impl SessionContext {
15661571 state. register_udf ( Arc :: new ( f) ) . ok ( ) ;
15671572 }
15681573
1574+ /// Registers a higher-order function within this context.
1575+ ///
1576+ /// Note in SQL queries, function names are looked up using
1577+ /// lowercase unless the query uses quotes. For example,
1578+ ///
1579+ /// - `SELECT MY_HIGHER_ORDER_FUNC(x)...` will look for a function named `"my_higher_order_func"`
1580+ /// - `SELECT "my_HIGHER_ORDER_FUNC"(x)` will look for a function named `"my_HIGHER_ORDER_FUNC"`
1581+ ///
1582+ /// Any functions registered with the function name or its aliases will be overwritten with this new function
1583+ pub fn register_higher_order_function ( & self , f : Arc < dyn HigherOrderUDF > ) {
1584+ let mut state = self . state . write ( ) ;
1585+ state. register_higher_order_function ( f) . ok ( ) ;
1586+ }
1587+
15691588 /// Registers an aggregate UDF within this context.
15701589 ///
15711590 /// Note in SQL queries, aggregate names are looked up using
@@ -1605,6 +1624,14 @@ impl SessionContext {
16051624 self . state . write ( ) . deregister_udf ( name) . ok ( ) ;
16061625 }
16071626
1627+ /// Deregisters a higher-order function within this context.
1628+ pub fn deregister_higher_order_function ( & self , name : & str ) {
1629+ self . state
1630+ . write ( )
1631+ . deregister_higher_order_function ( name)
1632+ . ok ( ) ;
1633+ }
1634+
16081635 /// Deregisters a UDAF within this context.
16091636 pub fn deregister_udaf ( & self , name : & str ) {
16101637 self . state . write ( ) . deregister_udaf ( name) . ok ( ) ;
0 commit comments