YuvrajVerma09arch opened a new issue, #27765:
URL: https://github.com/apache/datafusion/issues/27765
### Is your feature request related to a problem?
Apache DataFusion Python bindings cannot register Python defined analyzer
rules. `SessionContext.add_analyzer_rule` requires `Arc<dyn AnalyzerRule>`, and
`datafusion-ffi` 55.2.0 exposes only `FFI_PhysicalOptimizerRule` through
`from_pycapsule!` in `crates/util/src/lib.rs`. There is no analyzer equivalent.
This blocks apache/datafusion-python issue 1575. In that repo, PR 1557 tried
a pure Python adapter and was deliberately reverted in commit daa8da9:
LogicalPlan node pyclasses are frozen with getters only, so a Python rule can
observe a plan but cannot transform it.
### Describe the solution you would like
Add an `FFI_AnalyzerRule` to `datafusion-ffi`, mirroring
`FFI_PhysicalOptimizerRule`, so downstream language bindings can pass an
analyzer rule across the FFI boundary. The trait to bridge is:
`pub trait AnalyzerRule: Debug { fn analyze(&self, plan: LogicalPlan,
config: &ConfigOptions) -> Result<LogicalPlan>; fn name(&self) -> &str; }`
The needed shape follows `FFI_PhysicalOptimizerRule` in the current
`datafusion-ffi` crate.
### Describe alternatives you have considered
A pure Python rule using `datafusion.optimizer.AnalyzerRule` was implemented
and reverted in datafusion-python because plan variants cannot be constructed
or mutated from Python. Making those pyclasses mutable would be a much larger
API change.
### Additional context
Relevant source: `datafusion/core/src/execution/context/mod.rs:501` and
`datafusion/optimizer/src/analyzer/mod.rs:56` at tag 55.2.0. Once this bridge
exists, datafusion-python can add `add_analyzer_rule` with the FFI example test
pattern used for physical rules.
--
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]