Skip to content

Commit 0ea9df1

Browse files
committed
fix: fix clippy error
Signed-off-by: StandingMan <jmtangcs@gmail.com>
1 parent bb4dbe4 commit 0ea9df1

File tree

6 files changed

+40
-22
lines changed

6 files changed

+40
-22
lines changed

datafusion-examples/examples/relation_planner/match_recognize.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl RelationPlanner for MatchRecognizePlanner {
362362
..
363363
} = relation
364364
else {
365-
return Ok(RelationPlanning::Original(relation));
365+
return Ok(RelationPlanning::Original(Box::new(relation)));
366366
};
367367

368368
// Plan the input table
@@ -401,6 +401,8 @@ impl RelationPlanner for MatchRecognizePlanner {
401401
node: Arc::new(node),
402402
});
403403

404-
Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)))
404+
Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
405+
plan, alias,
406+
))))
405407
}
406408
}

datafusion-examples/examples/relation_planner/pivot_unpivot.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl RelationPlanner for PivotUnpivotPlanner {
339339
alias,
340340
),
341341

342-
other => Ok(RelationPlanning::Original(other)),
342+
other => Ok(RelationPlanning::Original(Box::new(other))),
343343
}
344344
}
345345
}
@@ -459,7 +459,9 @@ fn plan_pivot(
459459
.aggregate(group_by_cols, pivot_exprs)?
460460
.build()?;
461461

462-
Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)))
462+
Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
463+
plan, alias,
464+
))))
463465
}
464466

465467
// ============================================================================
@@ -540,7 +542,9 @@ fn plan_unpivot(
540542
.build()?;
541543
}
542544

543-
Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)))
545+
Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
546+
plan, alias,
547+
))))
544548
}
545549

546550
// ============================================================================

datafusion-examples/examples/relation_planner/table_sample.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl RelationPlanner for TableSamplePlanner {
331331
index_hints,
332332
} = relation
333333
else {
334-
return Ok(RelationPlanning::Original(relation));
334+
return Ok(RelationPlanning::Original(Box::new(relation)));
335335
};
336336

337337
// Extract sample spec (handles both before/after alias positions)
@@ -401,7 +401,9 @@ impl RelationPlanner for TableSamplePlanner {
401401

402402
let fraction = bucket_num as f64 / total as f64;
403403
let plan = TableSamplePlanNode::new(input, fraction, seed).into_plan();
404-
return Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)));
404+
return Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
405+
plan, alias,
406+
))));
405407
}
406408

407409
// Handle quantity-based sampling
@@ -422,15 +424,19 @@ impl RelationPlanner for TableSamplePlanner {
422424
let plan = LogicalPlanBuilder::from(input)
423425
.limit(0, Some(rows as usize))?
424426
.build()?;
425-
Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)))
427+
Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
428+
plan, alias,
429+
))))
426430
}
427431

428432
// TABLESAMPLE (N PERCENT) - percentage sampling
429433
Some(TableSampleUnit::Percent) => {
430434
let percent: f64 = parse_literal::<Float64Type>(&quantity_value_expr)?;
431435
let fraction = percent / 100.0;
432436
let plan = TableSamplePlanNode::new(input, fraction, seed).into_plan();
433-
Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)))
437+
Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
438+
plan, alias,
439+
))))
434440
}
435441

436442
// TABLESAMPLE (N) - fraction if <1.0, row limit if >=1.0
@@ -448,7 +454,9 @@ impl RelationPlanner for TableSamplePlanner {
448454
// Interpret as fraction
449455
TableSamplePlanNode::new(input, value, seed).into_plan()
450456
};
451-
Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)))
457+
Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
458+
plan, alias,
459+
))))
452460
}
453461
}
454462
}

datafusion/core/tests/user_defined/relation_planner.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ fn plan_static_values_table(
6868
.project(vec![col("column1").alias(column_name)])?
6969
.build()?;
7070

71-
Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)))
71+
Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
72+
plan, alias,
73+
))))
7274
}
73-
other => Ok(RelationPlanning::Original(other)),
75+
other => Ok(RelationPlanning::Original(Box::new(other))),
7476
}
7577
}
7678

@@ -176,9 +178,11 @@ impl RelationPlanner for SamplingJoinPlanner {
176178
.cross_join(right_sampled)?
177179
.build()?;
178180

179-
Ok(RelationPlanning::Planned(PlannedRelation::new(plan, alias)))
181+
Ok(RelationPlanning::Planned(Box::new(PlannedRelation::new(
182+
plan, alias,
183+
))))
180184
}
181-
other => Ok(RelationPlanning::Original(other)),
185+
other => Ok(RelationPlanning::Original(Box::new(other))),
182186
}
183187
}
184188
}
@@ -195,7 +199,7 @@ impl RelationPlanner for PassThroughPlanner {
195199
_context: &mut dyn RelationPlannerContext,
196200
) -> Result<RelationPlanning> {
197201
// Never handles anything - always delegates
198-
Ok(RelationPlanning::Original(relation))
202+
Ok(RelationPlanning::Original(Box::new(relation)))
199203
}
200204
}
201205

@@ -217,7 +221,7 @@ impl RelationPlanner for PremiumFeaturePlanner {
217221
to unlock advanced array operations."
218222
.to_string(),
219223
)),
220-
other => Ok(RelationPlanning::Original(other)),
224+
other => Ok(RelationPlanning::Original(Box::new(other))),
221225
}
222226
}
223227
}

datafusion/expr/src/planner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ impl PlannedRelation {
369369
#[derive(Debug)]
370370
pub enum RelationPlanning {
371371
/// The relation was successfully planned by an extension planner
372-
Planned(PlannedRelation),
372+
Planned(Box<PlannedRelation>),
373373
/// No extension planner handled the relation, return it for default processing
374-
Original(TableFactor),
374+
Original(Box<TableFactor>),
375375
}
376376

377377
/// Customize planning SQL table factors to [`LogicalPlan`]s.

datafusion/sql/src/relation/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
9393
match self.create_extension_relation(relation, planner_context)? {
9494
RelationPlanning::Planned(planned) => planned,
9595
RelationPlanning::Original(original) => {
96-
self.create_default_relation(original, planner_context)?
96+
Box::new(self.create_default_relation(*original, planner_context)?)
9797
}
9898
};
9999

@@ -112,7 +112,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
112112
) -> Result<RelationPlanning> {
113113
let planners = self.context_provider.get_relation_planners();
114114
if planners.is_empty() {
115-
return Ok(RelationPlanning::Original(relation));
115+
return Ok(RelationPlanning::Original(Box::new(relation)));
116116
}
117117

118118
let mut current_relation = relation;
@@ -127,12 +127,12 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
127127
return Ok(RelationPlanning::Planned(planned));
128128
}
129129
RelationPlanning::Original(original) => {
130-
current_relation = original;
130+
current_relation = *original;
131131
}
132132
}
133133
}
134134

135-
Ok(RelationPlanning::Original(current_relation))
135+
Ok(RelationPlanning::Original(Box::new(current_relation)))
136136
}
137137

138138
fn create_default_relation(

0 commit comments

Comments
 (0)