Skip to content

Commit 47026a2

Browse files
authored
Remove unecessary passing around of suffix: &str in pruning.rs's RequiredColumns (#10863)
* Remove unecessary passing around of &str suffix in RequiredColumns * fmt
1 parent 76f5110 commit 47026a2

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

datafusion/core/src/physical_optimizer/pruning.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,19 @@ impl RequiredColumns {
772772
column_expr: &Arc<dyn PhysicalExpr>,
773773
field: &Field,
774774
stat_type: StatisticsType,
775-
suffix: &str,
776775
) -> Result<Arc<dyn PhysicalExpr>> {
777776
let (idx, need_to_insert) = match self.find_stat_column(column, stat_type) {
778777
Some(idx) => (idx, false),
779778
None => (self.columns.len(), true),
780779
};
781780

781+
let suffix = match stat_type {
782+
StatisticsType::Min => "min",
783+
StatisticsType::Max => "max",
784+
StatisticsType::NullCount => "null_count",
785+
StatisticsType::RowCount => "row_count",
786+
};
787+
782788
let stat_column =
783789
phys_expr::Column::new(&format!("{}_{}", column.name(), suffix), idx);
784790

@@ -800,7 +806,7 @@ impl RequiredColumns {
800806
column_expr: &Arc<dyn PhysicalExpr>,
801807
field: &Field,
802808
) -> Result<Arc<dyn PhysicalExpr>> {
803-
self.stat_column_expr(column, column_expr, field, StatisticsType::Min, "min")
809+
self.stat_column_expr(column, column_expr, field, StatisticsType::Min)
804810
}
805811

806812
/// rewrite col --> col_max
@@ -810,7 +816,7 @@ impl RequiredColumns {
810816
column_expr: &Arc<dyn PhysicalExpr>,
811817
field: &Field,
812818
) -> Result<Arc<dyn PhysicalExpr>> {
813-
self.stat_column_expr(column, column_expr, field, StatisticsType::Max, "max")
819+
self.stat_column_expr(column, column_expr, field, StatisticsType::Max)
814820
}
815821

816822
/// rewrite col --> col_null_count
@@ -820,13 +826,7 @@ impl RequiredColumns {
820826
column_expr: &Arc<dyn PhysicalExpr>,
821827
field: &Field,
822828
) -> Result<Arc<dyn PhysicalExpr>> {
823-
self.stat_column_expr(
824-
column,
825-
column_expr,
826-
field,
827-
StatisticsType::NullCount,
828-
"null_count",
829-
)
829+
self.stat_column_expr(column, column_expr, field, StatisticsType::NullCount)
830830
}
831831

832832
/// rewrite col --> col_row_count
@@ -836,13 +836,7 @@ impl RequiredColumns {
836836
column_expr: &Arc<dyn PhysicalExpr>,
837837
field: &Field,
838838
) -> Result<Arc<dyn PhysicalExpr>> {
839-
self.stat_column_expr(
840-
column,
841-
column_expr,
842-
field,
843-
StatisticsType::RowCount,
844-
"row_count",
845-
)
839+
self.stat_column_expr(column, column_expr, field, StatisticsType::RowCount)
846840
}
847841
}
848842

0 commit comments

Comments
 (0)