@@ -23,10 +23,10 @@ pub use arrow::{ArrowFunctionSignature, ArrowScalarParams, VArrowScalar};
2323
2424/// Duckdb scalar function trait
2525pub trait VScalar : Sized {
26- /// Extra info set at registration time. Persists for the lifetime of the catalog entry.
26+ /// State set at registration time. Persists for the lifetime of the catalog entry.
2727 /// Shared across worker threads and invocations — must not be modified during execution.
2828 /// Must be `'static` as it is stored in DuckDB and may outlive the current stack frame.
29- type ExtraInfo : Sized + Send + Sync + ' static ;
29+ type State : Sized + Send + Sync + ' static ;
3030 /// The actual function
3131 ///
3232 /// # Safety
@@ -36,7 +36,7 @@ pub trait VScalar: Sized {
3636 /// - Dereferences multiple raw pointers (`func`).
3737 ///
3838 unsafe fn invoke (
39- extra_info : & Self :: ExtraInfo ,
39+ state : & Self :: State ,
4040 input : & mut DataChunkHandle ,
4141 output : & mut dyn WritableVector ,
4242 ) -> Result < ( ) , Box < dyn std:: error:: Error > > ;
@@ -133,41 +133,37 @@ where
133133}
134134
135135impl Connection {
136- /// Register the given ScalarFunction with default extra info .
136+ /// Register the given ScalarFunction with default state .
137137 #[ inline]
138138 pub fn register_scalar_function < S : VScalar > ( & self , name : & str ) -> crate :: Result < ( ) >
139139 where
140- S :: ExtraInfo : Default ,
140+ S :: State : Default ,
141141 {
142142 let set = ScalarFunctionSet :: new ( name) ;
143143 for signature in S :: signatures ( ) {
144144 let scalar_function = ScalarFunction :: new ( name) ?;
145145 signature. register_with_scalar ( & scalar_function) ;
146146 scalar_function. set_function ( Some ( scalar_func :: < S > ) ) ;
147- scalar_function. set_extra_info ( S :: ExtraInfo :: default ( ) ) ;
147+ scalar_function. set_extra_info ( S :: State :: default ( ) ) ;
148148 set. add_function ( scalar_function) ?;
149149 }
150150 self . db . borrow_mut ( ) . register_scalar_function_set ( set)
151151 }
152152
153- /// Register the given ScalarFunction with custom extra info .
153+ /// Register the given ScalarFunction with custom state .
154154 ///
155- /// The extra info is cloned once per function signature (overload) and stored in DuckDB's catalog.
155+ /// The state is cloned once per function signature (overload) and stored in DuckDB's catalog.
156156 #[ inline]
157- pub fn register_scalar_function_with_extra_info < S : VScalar > (
158- & self ,
159- name : & str ,
160- extra_info : & S :: ExtraInfo ,
161- ) -> crate :: Result < ( ) >
157+ pub fn register_scalar_function_with_state < S : VScalar > ( & self , name : & str , state : & S :: State ) -> crate :: Result < ( ) >
162158 where
163- S :: ExtraInfo : Clone ,
159+ S :: State : Clone ,
164160 {
165161 let set = ScalarFunctionSet :: new ( name) ;
166162 for signature in S :: signatures ( ) {
167163 let scalar_function = ScalarFunction :: new ( name) ?;
168164 signature. register_with_scalar ( & scalar_function) ;
169165 scalar_function. set_function ( Some ( scalar_func :: < S > ) ) ;
170- scalar_function. set_extra_info ( extra_info . clone ( ) ) ;
166+ scalar_function. set_extra_info ( state . clone ( ) ) ;
171167 set. add_function ( scalar_function) ?;
172168 }
173169 self . db . borrow_mut ( ) . register_scalar_function_set ( set)
@@ -200,10 +196,10 @@ mod test {
200196 struct ErrorScalar { }
201197
202198 impl VScalar for ErrorScalar {
203- type ExtraInfo = ( ) ;
199+ type State = ( ) ;
204200
205201 unsafe fn invoke (
206- _: & Self :: ExtraInfo ,
202+ _: & Self :: State ,
207203 input : & mut DataChunkHandle ,
208204 _: & mut dyn WritableVector ,
209205 ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
@@ -238,10 +234,10 @@ mod test {
238234 struct EchoScalar { }
239235
240236 impl VScalar for EchoScalar {
241- type ExtraInfo = TestState ;
237+ type State = TestState ;
242238
243239 unsafe fn invoke (
244- extra_info : & Self :: ExtraInfo ,
240+ state : & Self :: State ,
245241 input : & mut DataChunkHandle ,
246242 output : & mut dyn WritableVector ,
247243 ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
@@ -254,7 +250,7 @@ mod test {
254250 let output = output. flat_vector ( ) ;
255251
256252 for s in strings {
257- let res = format ! ( "{}: {}" , extra_info . prefix, s. repeat( extra_info . multiplier) ) ;
253+ let res = format ! ( "{}: {}" , state . prefix, s. repeat( state . multiplier) ) ;
258254 output. insert ( 0 , res. as_str ( ) ) ;
259255 }
260256 Ok ( ( ) )
@@ -271,10 +267,10 @@ mod test {
271267 struct Repeat { }
272268
273269 impl VScalar for Repeat {
274- type ExtraInfo = ( ) ;
270+ type State = ( ) ;
275271
276272 unsafe fn invoke (
277- _: & Self :: ExtraInfo ,
273+ _: & Self :: State ,
278274 input : & mut DataChunkHandle ,
279275 output : & mut dyn WritableVector ,
280276 ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
@@ -321,9 +317,9 @@ mod test {
321317 }
322318 }
323319
324- // Test with custom extra info
320+ // Test with custom state
325321 {
326- conn. register_scalar_function_with_extra_info :: < EchoScalar > (
322+ conn. register_scalar_function_with_state :: < EchoScalar > (
327323 "echo2" ,
328324 & TestState {
329325 multiplier : 5 ,
0 commit comments