alamb commented on a change in pull request #8031:
URL: https://github.com/apache/arrow/pull/8031#discussion_r475531252



##########
File path: rust/datafusion/src/execution/context.rs
##########
@@ -477,9 +466,9 @@ impl ExecutionConfig {
 /// Execution context for registering data sources and executing queries
 pub struct ExecutionContextState {
     /// Data sources that are registered with the context
-    pub datasources: Box<HashMap<String, Box<dyn TableProvider + Send + 
Sync>>>,
+    pub datasources: HashMap<String, Box<dyn TableProvider + Send + Sync>>,
     /// Scalar functions that are registered with the context
-    pub scalar_functions: Box<HashMap<String, Box<ScalarFunction>>>,
+    pub scalar_functions: HashMap<String, Arc<ScalarFunction>>,

Review comment:
       I originally changed `Box` to `Arc` to avoid a having to deep-copy the 
`ScalarFunction` object around.
   
   When I tried to  use just `ScalarFunction` without wrapping it in an `Arc` 
ref count, that meant the interface for `ScalarFunctionRegistry` looked like:
   
   ```
       fn lookup(&self, name: &str) -> Option<&ScalarFunction> {
   ```
   
   And I remember the Rust compiler did not seem to like the idea of returning 
references out of traits. I don't have the exact error handy and can't remember 
exactly was wrong. 
   
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to