Skip to content

Commit

Permalink
Remove unecessary passing around of suffix: &str in pruning.rs's …
Browse files Browse the repository at this point in the history
…`RequiredColumns` (#10863)

* Remove unecessary passing around of &str suffix in RequiredColumns

* fmt
  • Loading branch information
adriangb authored Jun 11, 2024
1 parent 76f5110 commit 47026a2
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions datafusion/core/src/physical_optimizer/pruning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,13 +772,19 @@ impl RequiredColumns {
column_expr: &Arc<dyn PhysicalExpr>,
field: &Field,
stat_type: StatisticsType,
suffix: &str,
) -> Result<Arc<dyn PhysicalExpr>> {
let (idx, need_to_insert) = match self.find_stat_column(column, stat_type) {
Some(idx) => (idx, false),
None => (self.columns.len(), true),
};

let suffix = match stat_type {
StatisticsType::Min => "min",
StatisticsType::Max => "max",
StatisticsType::NullCount => "null_count",
StatisticsType::RowCount => "row_count",
};

let stat_column =
phys_expr::Column::new(&format!("{}_{}", column.name(), suffix), idx);

Expand All @@ -800,7 +806,7 @@ impl RequiredColumns {
column_expr: &Arc<dyn PhysicalExpr>,
field: &Field,
) -> Result<Arc<dyn PhysicalExpr>> {
self.stat_column_expr(column, column_expr, field, StatisticsType::Min, "min")
self.stat_column_expr(column, column_expr, field, StatisticsType::Min)
}

/// rewrite col --> col_max
Expand All @@ -810,7 +816,7 @@ impl RequiredColumns {
column_expr: &Arc<dyn PhysicalExpr>,
field: &Field,
) -> Result<Arc<dyn PhysicalExpr>> {
self.stat_column_expr(column, column_expr, field, StatisticsType::Max, "max")
self.stat_column_expr(column, column_expr, field, StatisticsType::Max)
}

/// rewrite col --> col_null_count
Expand All @@ -820,13 +826,7 @@ impl RequiredColumns {
column_expr: &Arc<dyn PhysicalExpr>,
field: &Field,
) -> Result<Arc<dyn PhysicalExpr>> {
self.stat_column_expr(
column,
column_expr,
field,
StatisticsType::NullCount,
"null_count",
)
self.stat_column_expr(column, column_expr, field, StatisticsType::NullCount)
}

/// rewrite col --> col_row_count
Expand All @@ -836,13 +836,7 @@ impl RequiredColumns {
column_expr: &Arc<dyn PhysicalExpr>,
field: &Field,
) -> Result<Arc<dyn PhysicalExpr>> {
self.stat_column_expr(
column,
column_expr,
field,
StatisticsType::RowCount,
"row_count",
)
self.stat_column_expr(column, column_expr, field, StatisticsType::RowCount)
}
}

Expand Down

0 comments on commit 47026a2

Please sign in to comment.