Skip to content

Commit d8b754b

Browse files
committed
Refactor
1 parent 1fd80fd commit d8b754b

File tree

2 files changed

+5
-14
lines changed
  • datafusion
    • expr/src/logical_plan
    • optimizer/src/optimize_projections

2 files changed

+5
-14
lines changed

datafusion/expr/src/logical_plan/plan.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,18 +2683,9 @@ impl TableScan {
26832683
})
26842684
}
26852685

2686-
pub fn try_new_with_preferred_ordering(
2687-
table_name: impl Into<TableReference>,
2688-
table_source: Arc<dyn TableSource>,
2689-
projection: Option<Vec<usize>>,
2690-
filters: Vec<Expr>,
2691-
fetch: Option<usize>,
2692-
preferred_ordering: Option<Vec<SortExpr>>,
2693-
) -> Result<Self> {
2694-
let mut table_scan =
2695-
Self::try_new(table_name, table_source, projection, filters, fetch)?;
2696-
table_scan.preferred_ordering = preferred_ordering;
2697-
Ok(table_scan)
2686+
pub fn with_preferred_ordering(mut self, preferred_ordering: Option<Vec<SortExpr>>) -> Self {
2687+
self.preferred_ordering = preferred_ordering;
2688+
self
26982689
}
26992690
}
27002691

datafusion/optimizer/src/optimize_projections/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ fn optimize_projections(
251251
Some(projection) => indices.into_mapped_indices(|idx| projection[idx]),
252252
None => indices.into_inner(),
253253
};
254-
return TableScan::try_new_with_preferred_ordering(
254+
return TableScan::try_new(
255255
table_name,
256256
source,
257257
Some(projection),
258258
filters,
259259
fetch,
260-
preferred_ordering,
261260
)
261+
.map(|s| s.with_preferred_ordering(preferred_ordering))
262262
.map(LogicalPlan::TableScan)
263263
.map(Transformed::yes);
264264
}

0 commit comments

Comments
 (0)