nathanb9 commented on code in PR #22584:
URL: https://github.com/apache/datafusion/pull/22584#discussion_r3337749195
##########
datafusion/ffi/src/physical_optimizer.rs:
##########
@@ -98,6 +198,38 @@ unsafe extern "C" fn optimize_fn_wrapper(
FFI_Result::Ok(FFI_ExecutionPlan::new(optimized_plan, runtime))
}
+unsafe extern "C" fn optimize_with_context_fn_wrapper(
+ rule: &FFI_PhysicalOptimizerRule,
+ plan: &FFI_ExecutionPlan,
+ context: &FFI_PhysicalOptimizerContext,
+) -> FFI_Result<FFI_ExecutionPlan> {
+ let runtime = rule.runtime();
+ let inner = rule.inner();
+ let plan: Arc<dyn ExecutionPlan> = sresult_return!(plan.try_into());
+ let config = sresult_return!(ConfigOptions::try_from(unsafe {
+ (context.config_options)(context)
+ }));
+ let has_registry = unsafe { (context.has_statistics_registry)(context) };
+ let registry = if has_registry {
+ Some(
+ context
+ .inner()
Review Comment:
removing the `context.inner()` call in `optimize_with_context_fn_wrapper`
and always passing `statistics_registry: None` to the rule
##########
datafusion/ffi/src/physical_optimizer.rs:
##########
@@ -31,6 +32,99 @@ use crate::execution_plan::FFI_ExecutionPlan;
use crate::util::FFI_Result;
use crate::{df_result, sresult_return};
+/// A stable struct for sharing [`PhysicalOptimizerContext`] across FFI
boundaries.
+///
+/// This provides access to configuration options and an optional statistics
registry
+/// for optimizer rules that need extended context.
Review Comment:
New integration test `test_ffi_physical_optimizer_rule_with_context` which
has a `ContextAwareAddLimitRule` that errors `fromoptimize()` and only succeeds
via `optimize_with_context()`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]