Skip to content

Commit d905201

Browse files
committed
chore: document OptimizeProjections struct
1 parent 33b1950 commit d905201

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • datafusion/optimizer/src/optimize_projections

datafusion/optimizer/src/optimize_projections/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ use datafusion_common::tree_node::{
5555
/// The rule analyzes the input logical plan, determines the necessary column
5656
/// indices, and then removes any unnecessary columns. It also removes any
5757
/// unnecessary projections from the plan tree.
58+
///
59+
/// ## Schema, Field Properties, and Metadata Handling
60+
///
61+
/// The `OptimizeProjections` rule preserves schema and field metadata in most optimization scenarios:
62+
///
63+
/// **Schema-level metadata preservation by plan type**:
64+
/// - **Window and Aggregate plans**: Schema metadata is preserved
65+
/// - **Projection plans**: Schema metadata is preserved per [`projection_schema`](datafusion_expr::logical_plan::projection_schema).
66+
/// - **Other logical plans**: Schema metadata is preserved unless [`LogicalPlan::recompute_schema`]
67+
/// is called on plan types that drop metadata
68+
///
69+
/// **Field-level properties and metadata**: Individual field properties are preserved when fields
70+
/// are retained in the optimized plan, determined by [`exprlist_to_fields`](datafusion_expr::utils::exprlist_to_fields)
71+
/// and [`ExprSchemable::to_field`](datafusion_expr::expr_schema::ExprSchemable::to_field).
72+
///
73+
/// **Field precedence**: When the same field appears multiple times, the optimizer
74+
/// maintains one occurrence and removes duplicates (refer to `RequiredIndices::compact()`),
75+
/// preserving the properties and metadata of that occurrence.
5876
#[derive(Default, Debug)]
5977
pub struct OptimizeProjections {}
6078

0 commit comments

Comments
 (0)