Skip to content

Commit 73038f5

Browse files
chore: Format examples in doc strings - physical expr, optimizer, and plan (#18357)
## Which issue does this PR close? Part of #16915 ## Rationale for this change Format code examples in documentation comments to improve readability and maintain consistent code style across the codebase. This is part of a multi-PR effort to format all doc comment examples and eventually enable CI checks to enforce this formatting. ## What changes are included in this PR? Run `cargo fmt -p <crate> -- --config format_code_in_doc_comments=true` for the following datasource-related crates: - `datafusion-physical-expr` - `datafusion-physical-expr-adapter` - `datafusion-physical-expr-common` - `datafusion-physical-optimizer` - `datafusion-physical-plan` Additionally, add some spaces to maintain the ASCII art indentation. ## Are these changes tested? No testing needed - this is purely a formatting change with no functional modifications. ## Are there any user-facing changes? No - this only affects documentation formatting.
1 parent e969500 commit 73038f5

File tree

36 files changed

+106
-122
lines changed

36 files changed

+106
-122
lines changed

datafusion/physical-expr-common/src/physical_expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ pub trait PhysicalExpr: Any + Send + Sync + Display + Debug + DynEq + DynHash {
341341
/// representation.
342342
///
343343
/// See the [`fmt_sql`] function for an example of printing `PhysicalExpr`s as SQL.
344-
///
345344
fn fmt_sql(&self, f: &mut Formatter<'_>) -> fmt::Result;
346345

347346
/// Take a snapshot of this `PhysicalExpr`, if it is dynamic.

datafusion/physical-expr/src/equivalence/properties/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,14 @@ use itertools::Itertools;
123123
/// let mut eq_properties = EquivalenceProperties::new(schema);
124124
/// eq_properties.add_constants(vec![ConstExpr::from(col_b)]);
125125
/// eq_properties.add_ordering([
126-
/// PhysicalSortExpr::new_default(col_a).asc(),
127-
/// PhysicalSortExpr::new_default(col_c).desc(),
126+
/// PhysicalSortExpr::new_default(col_a).asc(),
127+
/// PhysicalSortExpr::new_default(col_c).desc(),
128128
/// ]);
129129
///
130-
/// assert_eq!(eq_properties.to_string(), "order: [[a@0 ASC, c@2 DESC]], eq: [{members: [b@1], constant: (heterogeneous)}]");
130+
/// assert_eq!(
131+
/// eq_properties.to_string(),
132+
/// "order: [[a@0 ASC, c@2 DESC]], eq: [{members: [b@1], constant: (heterogeneous)}]"
133+
/// );
131134
/// ```
132135
#[derive(Clone, Debug)]
133136
pub struct EquivalenceProperties {

datafusion/physical-expr/src/expressions/case.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ fn filter_array(
341341
/// │└─────────┘│ │ 2 │ │ D │
342342
/// └───────────┘ └─────────┘ └─────────┘
343343
/// values indices result
344-
///
345344
/// ```
346345
fn merge(values: &[ArrayData], indices: &[PartialResultIndex]) -> Result<ArrayRef> {
347346
#[cfg(debug_assertions)]

datafusion/physical-expr/src/expressions/column.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ use datafusion_expr::ColumnarValue;
4949
/// # use arrow::datatypes::{DataType, Field, Schema};
5050
/// // Schema with columns a, b, c
5151
/// let schema = Schema::new(vec![
52-
/// Field::new("a", DataType::Int32, false),
53-
/// Field::new("b", DataType::Int32, false),
54-
/// Field::new("c", DataType::Int32, false),
52+
/// Field::new("a", DataType::Int32, false),
53+
/// Field::new("b", DataType::Int32, false),
54+
/// Field::new("c", DataType::Int32, false),
5555
/// ]);
5656
///
5757
/// // reference to column b is index 1

datafusion/physical-expr/src/intervals/cp_solver.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,15 +579,11 @@ impl ExprIntervalGraph {
579579
///
580580
/// let mut graph = ExprIntervalGraph::try_new(expr, &schema).unwrap();
581581
/// // Do it once, while constructing.
582-
/// let node_indices = graph
583-
/// .gather_node_indices(&[Arc::new(Column::new("gnz", 0))]);
582+
/// let node_indices = graph.gather_node_indices(&[Arc::new(Column::new("gnz", 0))]);
584583
/// let left_index = node_indices.get(0).unwrap().1;
585584
///
586585
/// // Provide intervals for leaf variables (here, there is only one).
587-
/// let intervals = vec![(
588-
/// left_index,
589-
/// Interval::make(Some(10), Some(20)).unwrap(),
590-
/// )];
586+
/// let intervals = vec![(left_index, Interval::make(Some(10), Some(20)).unwrap())];
591587
///
592588
/// // Evaluate bounds for the composite expression:
593589
/// graph.assign_intervals(&intervals);

datafusion/physical-expr/src/physical_expr.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,16 @@ pub fn physical_exprs_bag_equal(
118118
/// ]);
119119
///
120120
/// let sort_exprs = vec![
121-
/// vec![
122-
/// SortExpr { expr: Expr::Column(Column::new(Some("t"), "id")), asc: true, nulls_first: false }
123-
/// ],
124-
/// vec![
125-
/// SortExpr { expr: Expr::Column(Column::new(Some("t"), "name")), asc: false, nulls_first: true }
126-
/// ]
121+
/// vec![SortExpr {
122+
/// expr: Expr::Column(Column::new(Some("t"), "id")),
123+
/// asc: true,
124+
/// nulls_first: false,
125+
/// }],
126+
/// vec![SortExpr {
127+
/// expr: Expr::Column(Column::new(Some("t"), "name")),
128+
/// asc: false,
129+
/// nulls_first: true,
130+
/// }],
127131
/// ];
128132
/// let result = create_ordering(&schema, &sort_exprs).unwrap();
129133
/// ```

datafusion/physical-expr/src/projection.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ impl ProjectionExprs {
166166
/// # Example
167167
///
168168
/// ```rust
169-
/// use std::sync::Arc;
170-
/// use arrow::datatypes::{Schema, Field, DataType};
169+
/// use arrow::datatypes::{DataType, Field, Schema};
171170
/// use datafusion_physical_expr::projection::ProjectionExprs;
171+
/// use std::sync::Arc;
172172
///
173173
/// // Create a schema with three columns
174174
/// let schema = Arc::new(Schema::new(vec![
@@ -234,11 +234,11 @@ impl ProjectionExprs {
234234
/// # Example
235235
///
236236
/// ```rust
237-
/// use std::sync::Arc;
238-
/// use datafusion_physical_expr::projection::{ProjectionExprs, ProjectionExpr};
239-
/// use datafusion_physical_expr::expressions::{Column, BinaryExpr, Literal};
240237
/// use datafusion_common::{Result, ScalarValue};
241238
/// use datafusion_expr::Operator;
239+
/// use datafusion_physical_expr::expressions::{BinaryExpr, Column, Literal};
240+
/// use datafusion_physical_expr::projection::{ProjectionExpr, ProjectionExprs};
241+
/// use std::sync::Arc;
242242
///
243243
/// fn main() -> Result<()> {
244244
/// // Example from the docstring:

datafusion/physical-optimizer/src/combine_partial_final_agg.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use datafusion_physical_expr::{physical_exprs_equal, PhysicalExpr};
3636
/// into a Single AggregateExec if their grouping exprs and aggregate exprs equal.
3737
///
3838
/// This rule should be applied after the EnforceDistribution and EnforceSorting rules
39-
///
4039
#[derive(Default, Debug)]
4140
pub struct CombinePartialFinalAggregate {}
4241

datafusion/physical-optimizer/src/enforce_distribution.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ pub type PlanWithKeyRequirements = PlanContext<Vec<Arc<dyn PhysicalExpr>>>;
281281
/// 3) If the current plan is RepartitionExec, CoalescePartitionsExec or WindowAggExec, clear all the requirements, return the unchanged plan
282282
/// 4) If the current plan is Projection, transform the requirements to the columns before the Projection and push down requirements
283283
/// 5) For other types of operators, by default, pushdown the parent requirements to children.
284-
///
285284
pub fn adjust_input_keys_ordering(
286285
mut requirements: PlanWithKeyRequirements,
287286
) -> Result<Transformed<PlanWithKeyRequirements>> {

datafusion/physical-optimizer/src/join_selection.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ fn hash_join_convert_symmetric_subrule(
476476
/// | Data Source |--------------| Repartition |
477477
/// | | | |
478478
/// +--------------+ +--------------+
479-
///
480479
/// ```
481480
pub fn hash_join_swap_subrule(
482481
mut input: Arc<dyn ExecutionPlan>,

0 commit comments

Comments
 (0)