Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unecessary passing around of suffix: &str in pruning.rs's RequiredColumns #10863

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading