| 402 | impl TryFrom<&FFI_SessionRef> for ForeignSession { |
| 403 | type Error = DataFusionError; |
| 404 | fn try_from(session: &FFI_SessionRef) -> Result<Self, Self::Error> { |
| 405 | unsafe { |
| 406 | let table_options = |
| 407 | table_options_from_rhashmap((session.table_options)(session)); |
| 408 | |
| 409 | let config = (session.config)(session); |
| 410 | let config = SessionConfig::try_from(&config)?; |
| 411 | |
| 412 | let scalar_functions = (session.scalar_functions)(session) |
| 413 | .into_iter() |
| 414 | .map(|kv_pair| { |
| 415 | let udf = <Arc<dyn ScalarUDFImpl>>::from(&kv_pair.1); |
| 416 | |
| 417 | ( |
| 418 | kv_pair.0.to_string(), |
| 419 | Arc::new(ScalarUDF::new_from_shared_impl(udf)), |
| 420 | ) |
| 421 | }) |
| 422 | .collect(); |
| 423 | let aggregate_functions = (session.aggregate_functions)(session) |
| 424 | .into_iter() |
| 425 | .map(|kv_pair| { |
| 426 | let udaf = <Arc<dyn AggregateUDFImpl>>::from(&kv_pair.1); |
| 427 | |
| 428 | ( |
| 429 | kv_pair.0.to_string(), |
| 430 | Arc::new(AggregateUDF::new_from_shared_impl(udaf)), |
| 431 | ) |
| 432 | }) |
| 433 | .collect(); |
| 434 | let window_functions = (session.window_functions)(session) |
| 435 | .into_iter() |
| 436 | .map(|kv_pair| { |
| 437 | let udwf = <Arc<dyn WindowUDFImpl>>::from(&kv_pair.1); |
| 438 | |
| 439 | ( |
| 440 | kv_pair.0.to_string(), |
| 441 | Arc::new(WindowUDF::new_from_shared_impl(udwf)), |
| 442 | ) |
| 443 | }) |
| 444 | .collect(); |
| 445 | |
| 446 | Ok(Self { |
| 447 | session: session.clone(), |
| 448 | config, |
| 449 | table_options, |
| 450 | scalar_functions, |
| 451 | higher_order_functions: HashMap::new(), |
| 452 | aggregate_functions, |
| 453 | window_functions, |
| 454 | extension_types: Arc::new(MemoryExtensionTypeRegistry::default()), |
| 455 | runtime_env: Default::default(), |
| 456 | props: Default::default(), |
| 457 | }) |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |