Skip to content

Commit 7fff40a

Browse files
committed
add upgrade guide
1 parent 0c21301 commit 7fff40a

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

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

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,109 @@ Instead of silently succeeding.
451451

452452
The remove API no longer requires a mutable instance
453453

454+
### `SimplifyInfo` trait removed, `SimplifyContext` now uses builder-style API
455+
456+
The `SimplifyInfo` trait has been removed and replaced with the concrete `SimplifyContext` struct. This simplifies the expression simplification API and removes the need for trait objects.
457+
458+
**Who is affected:**
459+
460+
- Users who implemented custom `SimplifyInfo` implementations
461+
- Users who implemented `ScalarUDFImpl::simplify()` for custom scalar functions
462+
- Users who directly use `SimplifyContext` or `ExprSimplifier`
463+
464+
**Breaking changes:**
465+
466+
1. The `SimplifyInfo` trait has been removed entirely
467+
2. `SimplifyContext` no longer takes `&ExecutionProps` - it now uses a builder-style API with direct fields
468+
3. `ScalarUDFImpl::simplify()` now takes `&SimplifyContext` instead of `&dyn SimplifyInfo`
469+
4. Time-dependent function simplification (e.g., `now()`) is now optional - if `query_execution_start_time` is `None`, these functions won't be simplified
470+
471+
**Migration guide:**
472+
473+
If you implemented a custom `SimplifyInfo`:
474+
475+
**Before:**
476+
477+
```rust,ignore
478+
impl SimplifyInfo for MySimplifyInfo {
479+
fn is_boolean_type(&self, expr: &Expr) -> Result<bool> { ... }
480+
fn nullable(&self, expr: &Expr) -> Result<bool> { ... }
481+
fn execution_props(&self) -> &ExecutionProps { ... }
482+
fn get_data_type(&self, expr: &Expr) -> Result<DataType> { ... }
483+
}
484+
```
485+
486+
**After:**
487+
488+
Use `SimplifyContext` directly with the builder-style API:
489+
490+
```rust,ignore
491+
let context = SimplifyContext::default()
492+
.with_schema(schema)
493+
.with_config_options(config_options)
494+
.with_query_execution_start_time(Some(Utc::now())); // or use .with_current_time()
495+
```
496+
497+
If you implemented `ScalarUDFImpl::simplify()`:
498+
499+
**Before:**
500+
501+
```rust,ignore
502+
fn simplify(
503+
&self,
504+
args: Vec<Expr>,
505+
info: &dyn SimplifyInfo,
506+
) -> Result<ExprSimplifyResult> {
507+
let now_ts = info.execution_props().query_execution_start_time;
508+
// ...
509+
}
510+
```
511+
512+
**After:**
513+
514+
```rust,ignore
515+
fn simplify(
516+
&self,
517+
args: Vec<Expr>,
518+
info: &SimplifyContext,
519+
) -> Result<ExprSimplifyResult> {
520+
// query_execution_start_time is now Option<DateTime<Utc>>
521+
// Return Original if time is not set (simplification skipped)
522+
let Some(now_ts) = info.query_execution_start_time() else {
523+
return Ok(ExprSimplifyResult::Original(args));
524+
};
525+
// ...
526+
}
527+
```
528+
529+
If you created `SimplifyContext` from `ExecutionProps`:
530+
531+
**Before:**
532+
533+
```rust,ignore
534+
let props = ExecutionProps::new();
535+
let context = SimplifyContext::new(&props).with_schema(schema);
536+
```
537+
538+
**After:**
539+
540+
```rust,ignore
541+
let context = SimplifyContext::default()
542+
.with_schema(schema)
543+
.with_config_options(config_options)
544+
.with_current_time(); // Sets query_execution_start_time to Utc::now()
545+
```
546+
547+
**Available `SimplifyContext` methods:**
548+
549+
- `with_schema(DFSchemaRef)` - Set the schema for type resolution
550+
- `with_config_options(Arc<ConfigOptions>)` - Set configuration options
551+
- `with_query_execution_start_time(Option<DateTime<Utc>>)` - Set query start time for time-dependent simplification
552+
- `with_current_time()` - Convenience method to set query start time to `Utc::now()`
553+
- `schema()` - Get the schema
554+
- `query_execution_start_time()` - Get the query start time (returns `Option<DateTime<Utc>>`)
555+
- `config_options()` - Get the configuration options
556+
454557
### FFI crate updates
455558

456559
Many of the structs in the `datafusion-ffi` crate have been updated to allow easier

0 commit comments

Comments
 (0)