Skip to content

Commit

Permalink
clean up code (#8715)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H authored Jan 2, 2024
1 parent f4233a9 commit 82656af
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions datafusion/core/src/datasource/file_format/write/demux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ fn compute_take_arrays(

fn remove_partition_by_columns(
parted_batch: &RecordBatch,
partition_by: &Vec<(String, DataType)>,
partition_by: &[(String, DataType)],
) -> Result<RecordBatch> {
let end_idx = parted_batch.num_columns() - partition_by.len();
let non_part_cols = &parted_batch.columns()[..end_idx];
Expand All @@ -405,7 +405,7 @@ fn remove_partition_by_columns(
}

fn compute_hive_style_file_path(
part_key: &Vec<String>,
part_key: &[String],
partition_by: &[(String, DataType)],
write_id: &str,
file_extension: &str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ fn prune_pages_in_one_row_group(
}

fn create_row_count_in_each_page(
location: &Vec<PageLocation>,
location: &[PageLocation],
num_rows: usize,
) -> Vec<usize> {
let mut vec = Vec::with_capacity(location.len());
Expand Down
10 changes: 6 additions & 4 deletions datafusion/core/src/execution/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,15 +1719,16 @@ impl SessionState {
let mut stringified_plans = e.stringified_plans.clone();

// analyze & capture output of each rule
let analyzed_plan = match self.analyzer.execute_and_check(
let analyzer_result = self.analyzer.execute_and_check(
e.plan.as_ref(),
self.options(),
|analyzed_plan, analyzer| {
let analyzer_name = analyzer.name().to_string();
let plan_type = PlanType::AnalyzedLogicalPlan { analyzer_name };
stringified_plans.push(analyzed_plan.to_stringified(plan_type));
},
) {
);
let analyzed_plan = match analyzer_result {
Ok(plan) => plan,
Err(DataFusionError::Context(analyzer_name, err)) => {
let plan_type = PlanType::AnalyzedLogicalPlan { analyzer_name };
Expand All @@ -1750,15 +1751,16 @@ impl SessionState {
.push(analyzed_plan.to_stringified(PlanType::FinalAnalyzedLogicalPlan));

// optimize the child plan, capturing the output of each optimizer
let (plan, logical_optimization_succeeded) = match self.optimizer.optimize(
let optimized_plan = self.optimizer.optimize(
&analyzed_plan,
self,
|optimized_plan, optimizer| {
let optimizer_name = optimizer.name().to_string();
let plan_type = PlanType::OptimizedLogicalPlan { optimizer_name };
stringified_plans.push(optimized_plan.to_stringified(plan_type));
},
) {
);
let (plan, logical_optimization_succeeded) = match optimized_plan {
Ok(plan) => (Arc::new(plan), true),
Err(DataFusionError::Context(optimizer_name, err)) => {
let plan_type = PlanType::OptimizedLogicalPlan { optimizer_name };
Expand Down
4 changes: 1 addition & 3 deletions datafusion/core/src/physical_optimizer/sort_pushdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,7 @@ fn shift_right_required(
let new_right_required: Vec<PhysicalSortRequirement> = parent_required
.iter()
.filter_map(|r| {
let Some(col) = r.expr.as_any().downcast_ref::<Column>() else {
return None;
};
let col = r.expr.as_any().downcast_ref::<Column>()?;

if col.index() < left_columns_len {
return None;
Expand Down
5 changes: 3 additions & 2 deletions datafusion/core/src/physical_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ impl DefaultPhysicalPlanner {
);
}

match self.optimize_internal(
let optimized_plan = self.optimize_internal(
input,
session_state,
|plan, optimizer| {
Expand All @@ -1891,7 +1891,8 @@ impl DefaultPhysicalPlanner {
.to_stringified(e.verbose, plan_type),
);
},
) {
);
match optimized_plan {
Ok(input) => {
// This plan will includes statistics if show_statistics is on
stringified_plans.push(
Expand Down
2 changes: 1 addition & 1 deletion datafusion/substrait/src/logical_plan/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ pub fn parse_flat_grouping_exprs(

pub fn to_substrait_groupings(
ctx: &SessionContext,
exprs: &Vec<Expr>,
exprs: &[Expr],
schema: &DFSchemaRef,
extension_info: &mut (
Vec<extensions::SimpleExtensionDeclaration>,
Expand Down

0 comments on commit 82656af

Please sign in to comment.