Skip to content

Commit e84a6c0

Browse files
committed
Refactor
1 parent 07ace97 commit e84a6c0

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
@@ -2656,18 +2656,9 @@ impl TableScan {
26562656
})
26572657
}
26582658

2659-
pub fn try_new_with_preferred_ordering(
2660-
table_name: impl Into<TableReference>,
2661-
table_source: Arc<dyn TableSource>,
2662-
projection: Option<Vec<usize>>,
2663-
filters: Vec<Expr>,
2664-
fetch: Option<usize>,
2665-
preferred_ordering: Option<Vec<SortExpr>>,
2666-
) -> Result<Self> {
2667-
let mut table_scan =
2668-
Self::try_new(table_name, table_source, projection, filters, fetch)?;
2669-
table_scan.preferred_ordering = preferred_ordering;
2670-
Ok(table_scan)
2659+
pub fn with_preferred_ordering(mut self, preferred_ordering: Option<Vec<SortExpr>>) -> Self {
2660+
self.preferred_ordering = preferred_ordering;
2661+
self
26712662
}
26722663
}
26732664

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)