Skip to content

Commit 447741a

Browse files
committed
Revert "Add upgrade guide for PhysicalOptimizerRule::optimize_plan (apache#19030)"
This reverts commit 7b4593f.
1 parent e54c8c6 commit 447741a

1 file changed

Lines changed: 0 additions & 96 deletions

File tree

docs/source/library-user-guide/upgrading.md

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -380,102 +380,6 @@ If you were using a custom `SchemaAdapterFactory` for schema adaptation (e.g., d
380380

381381
See the [default column values example](https://github.com/apache/datafusion/blob/main/datafusion-examples/examples/custom_data_source/default_column_values.rs) for how to implement a custom `PhysicalExprAdapterFactory`.
382382

383-
### `PhysicalOptimizerRule::optimize` deprecated in favor of `optimize_plan`
384-
385-
The `PhysicalOptimizerRule` trait has been updated to provide optimizer rules with access to broader session context. A new method `optimize_plan` has been added that accepts an `OptimizerContext` parameter, and the existing `optimize` method has been deprecated.
386-
387-
**Who is affected:**
388-
389-
- Users who have implemented custom `PhysicalOptimizerRule` implementations
390-
391-
**Breaking changes:**
392-
393-
1. **New `optimize_plan` method**: This is the preferred method for implementing optimization rules. It provides access to the full `SessionConfig` through `OptimizerContext`, rather than just `ConfigOptions`.
394-
395-
2. **`optimize` method deprecated**: The old `optimize` method that takes `&ConfigOptions` is now deprecated and will be removed in DataFusion 58.0.0.
396-
397-
**Migration guide:**
398-
399-
If you have a custom `PhysicalOptimizerRule` implementation, update it to implement `optimize_plan` instead of `optimize`:
400-
401-
**Before:**
402-
403-
```rust
404-
use datafusion::physical_optimizer::PhysicalOptimizerRule;
405-
use datafusion_common::config::ConfigOptions;
406-
use datafusion_common::Result;
407-
use datafusion_physical_plan::ExecutionPlan;
408-
use std::sync::Arc;
409-
410-
#[derive(Debug)]
411-
struct MyOptimizerRule;
412-
413-
#[allow(deprecated)]
414-
impl PhysicalOptimizerRule for MyOptimizerRule {
415-
fn optimize(
416-
&self,
417-
plan: Arc<dyn ExecutionPlan>,
418-
_config: &ConfigOptions,
419-
) -> Result<Arc<dyn ExecutionPlan>> {
420-
// Use config.optimizer, config.execution, etc.
421-
// ... optimization logic ...
422-
Ok(plan)
423-
}
424-
425-
fn name(&self) -> &str {
426-
"my_optimizer_rule"
427-
}
428-
429-
fn schema_check(&self) -> bool {
430-
true
431-
}
432-
}
433-
```
434-
435-
**After:**
436-
437-
```rust
438-
use datafusion::physical_optimizer::{OptimizerContext, PhysicalOptimizerRule};
439-
use datafusion_common::Result;
440-
use datafusion_physical_plan::ExecutionPlan;
441-
use std::sync::Arc;
442-
443-
#[derive(Debug)]
444-
struct MyOptimizerRule;
445-
446-
impl PhysicalOptimizerRule for MyOptimizerRule {
447-
fn optimize_plan(
448-
&self,
449-
plan: Arc<dyn ExecutionPlan>,
450-
context: &OptimizerContext,
451-
) -> Result<Arc<dyn ExecutionPlan>> {
452-
// Access ConfigOptions through session_config
453-
let _config = context.session_config().options();
454-
// Or access extensions through session_config
455-
let _extensions = context.session_config().extensions();
456-
// ... optimization logic ...
457-
Ok(plan)
458-
}
459-
460-
fn name(&self) -> &str {
461-
"my_optimizer_rule"
462-
}
463-
464-
fn schema_check(&self) -> bool {
465-
true
466-
}
467-
}
468-
```
469-
470-
**What is `OptimizerContext`?**
471-
472-
`OptimizerContext` is a new struct that provides context during physical plan optimization, similar to how `TaskContext` provides context during execution. It wraps `SessionConfig`, giving optimizer rules access to:
473-
474-
- Configuration options via `context.session_config().options()`
475-
- Session extensions via `context.session_config().extensions()`
476-
477-
This enables optimizer rules to access custom extensions registered with the session, which was not possible with the old `&ConfigOptions` parameter.
478-
479383
## DataFusion `51.0.0`
480384

481385
### `arrow` / `parquet` updated to 57.0.0

0 commit comments

Comments
 (0)