diff --git a/datafusion/core/src/lib.rs b/datafusion/core/src/lib.rs index 04378b3d83e0f..0716fd394979a 100644 --- a/datafusion/core/src/lib.rs +++ b/datafusion/core/src/lib.rs @@ -1197,6 +1197,12 @@ doc_comment::doctest!( library_user_guide_working_with_exprs ); +#[cfg(doctest)] +doc_comment::doctest!( + "../../../docs/source/library-user-guide/upgrading/index.md", + library_user_guide_upgrading +); + #[cfg(doctest)] doc_comment::doctest!( "../../../docs/source/contributor-guide/api-health.md", diff --git a/docs/source/library-user-guide/upgrading/index.md b/docs/source/library-user-guide/upgrading/index.md index 686d68bb58c2c..30f3165bcc809 100644 --- a/docs/source/library-user-guide/upgrading/index.md +++ b/docs/source/library-user-guide/upgrading/index.md @@ -225,9 +225,18 @@ has fields. Before, this could panic or return another column's values. Start from `Statistics::new_unknown`, or project a child's statistics with `Statistics::project` if the plan changes its columns: -```rust,ignore +```rust +# use datafusion::arrow::datatypes::SchemaRef; +# use datafusion::common::{Statistics, stats::Precision}; +# struct MyExec { schema: SchemaRef } +# impl MyExec { +# fn schema(&self) -> SchemaRef { self.schema.clone() } +# fn statistics(&self, num_rows: usize) -> Statistics { let statistics = Statistics::new_unknown(&self.schema()) .with_num_rows(Precision::Exact(num_rows)); +# statistics +# } +# } ``` ### Materialized CTE scans have a projection @@ -265,7 +274,22 @@ The existing seven-argument `SortMergeJoinExec::try_new` continues to create a non-null-aware join. Enable null-aware semantics with `.with_null_aware(true)?`: -```rust,ignore +```rust +# use std::sync::Arc; +# use datafusion::arrow::compute::SortOptions; +# use datafusion::arrow::datatypes::{DataType, Field, Schema}; +# use datafusion::common::{JoinType, NullEquality}; +# use datafusion::error::Result; +# use datafusion::physical_expr::expressions::Column; +# use datafusion::physical_plan::ExecutionPlan; +# use datafusion::physical_plan::empty::EmptyExec; +# use datafusion::physical_plan::joins::SortMergeJoinExec; +# use datafusion::physical_plan::joins::utils::JoinOn; +# fn main() -> Result<()> { +# let schema = Arc::new(Schema::new(vec![Field::new("a", DataType::Int32, true)])); +# let left: Arc = Arc::new(EmptyExec::new(Arc::clone(&schema))); +# let right: Arc = Arc::new(EmptyExec::new(schema)); +# let on: JoinOn = vec![(Arc::new(Column::new("a", 0)), Arc::new(Column::new("a", 0)))]; let exec = SortMergeJoinExec::try_new( left, right, @@ -276,6 +300,8 @@ let exec = SortMergeJoinExec::try_new( NullEquality::NullEqualsNothing, )? .with_null_aware(true)?; +# Ok(()) +# } ``` Both inputs must have a single partition when executed. @@ -284,6 +310,8 @@ The generated protobuf `SortMergeJoinExecNode` type has a new `null_aware` field. Exhaustive struct literals must initialize it; `false` preserves the previous behavior: + + ```rust,ignore let node = SortMergeJoinExecNode { left, @@ -316,8 +344,16 @@ computed expression as not determined. **Migration guide:** -```rust,ignore +```rust +# use datafusion::common::{ +# DFSchema, aggregate_functional_dependencies, +# aggregate_functional_dependencies_with_computed_inputs, +# }; +# let (input_schema, aggr_schema) = (&DFSchema::empty(), &DFSchema::empty()); +# let group_by_input_indices: Vec> = vec![]; +# let computed_input_indices: Vec>> = vec![]; // Before +# #[expect(deprecated)] let deps = aggregate_functional_dependencies(input_schema, &group_by_input_indices, aggr_schema); // After @@ -343,6 +379,8 @@ the name `""`. **Migration guide:** + + ```rust,ignore // Before let arg_types: Vec = args.iter().map(|a| a.data_type.clone()).collect(); @@ -370,6 +408,7 @@ Code that constructs these structs with an exhaustive struct literal must add the field or use `..Default::default()`. Builder methods are unaffected: ```rust +# use datafusion::prelude::CsvReadOptions; // 56.0.0 let options = CsvReadOptions { has_header: true,