Skip to content

Commit 880e6fc

Browse files
authored
rename (#4284)
1 parent 446c2ea commit 880e6fc

File tree

9 files changed

+88
-99
lines changed

9 files changed

+88
-99
lines changed

datafusion/expr/src/logical_plan/builder.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ impl LogicalPlanBuilder {
410410
Ok(Self::from(LogicalPlan::Projection(Projection::try_new(
411411
new_expr,
412412
Arc::new(sort_plan),
413-
None,
414413
)?)))
415414
}
416415

@@ -874,12 +873,12 @@ pub fn project_with_column_index_alias(
874873
x => x.alias(schema.field(i).name()),
875874
})
876875
.collect::<Vec<_>>();
877-
Ok(LogicalPlan::Projection(Projection::try_new_with_schema(
878-
alias_expr, input, schema, alias,
879-
)?))
876+
Ok(LogicalPlan::Projection(
877+
Projection::try_new_with_schema_alias(alias_expr, input, schema, alias)?,
878+
))
880879
}
881880

882-
/// Union two logical plans with an optional alias.
881+
/// Union two logical plans.
883882
pub fn union(left_plan: LogicalPlan, right_plan: LogicalPlan) -> Result<LogicalPlan> {
884883
let left_col_num = left_plan.schema().fields().len();
885884

@@ -986,12 +985,14 @@ pub fn project_with_alias(
986985
None => input_schema,
987986
};
988987

989-
Ok(LogicalPlan::Projection(Projection::try_new_with_schema(
990-
projected_expr,
991-
Arc::new(plan.clone()),
992-
DFSchemaRef::new(schema),
993-
alias,
994-
)?))
988+
Ok(LogicalPlan::Projection(
989+
Projection::try_new_with_schema_alias(
990+
projected_expr,
991+
Arc::new(plan.clone()),
992+
DFSchemaRef::new(schema),
993+
alias,
994+
)?,
995+
))
995996
}
996997

997998
/// Create a LogicalPlanBuilder representing a scan of a table with the provided name and schema.

datafusion/expr/src/logical_plan/plan.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,20 +1118,28 @@ impl Projection {
11181118
pub fn try_new(
11191119
expr: Vec<Expr>,
11201120
input: Arc<LogicalPlan>,
1121-
alias: Option<String>,
11221121
) -> Result<Self, DataFusionError> {
11231122
let schema = Arc::new(DFSchema::new_with_metadata(
11241123
exprlist_to_fields(&expr, &input)?,
11251124
input.schema().metadata().clone(),
11261125
)?);
1127-
Self::try_new_with_schema(expr, input, schema, alias)
1126+
Self::try_new_with_schema(expr, input, schema)
11281127
}
11291128

11301129
/// Create a new Projection using the specified output schema
11311130
pub fn try_new_with_schema(
11321131
expr: Vec<Expr>,
11331132
input: Arc<LogicalPlan>,
11341133
schema: DFSchemaRef,
1134+
) -> Result<Self, DataFusionError> {
1135+
Self::try_new_with_schema_alias(expr, input, schema, None)
1136+
}
1137+
1138+
/// Create a new Projection using the specified output schema
1139+
pub fn try_new_with_schema_alias(
1140+
expr: Vec<Expr>,
1141+
input: Arc<LogicalPlan>,
1142+
schema: DFSchemaRef,
11351143
alias: Option<String>,
11361144
) -> Result<Self, DataFusionError> {
11371145
if expr.len() != schema.fields().len() {
@@ -1146,11 +1154,7 @@ impl Projection {
11461154
}
11471155

11481156
/// Create a new Projection using the specified output schema
1149-
pub fn new_from_schema(
1150-
input: Arc<LogicalPlan>,
1151-
schema: DFSchemaRef,
1152-
alias: Option<String>,
1153-
) -> Self {
1157+
pub fn new_from_schema(input: Arc<LogicalPlan>, schema: DFSchemaRef) -> Self {
11541158
let expr: Vec<Expr> = schema
11551159
.fields()
11561160
.iter()
@@ -1161,7 +1165,7 @@ impl Projection {
11611165
expr,
11621166
input,
11631167
schema,
1164-
alias,
1168+
alias: None,
11651169
}
11661170
}
11671171

@@ -1990,7 +1994,6 @@ mod tests {
19901994
schema: empty_schema.clone(),
19911995
})),
19921996
empty_schema,
1993-
None,
19941997
);
19951998
assert_eq!("Error during planning: Projection has mismatch between number of expressions (1) and number of fields in schema (0)", format!("{}", p.err().unwrap()));
19961999
Ok(())

datafusion/expr/src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,14 @@ pub fn from_plan(
366366
inputs: &[LogicalPlan],
367367
) -> Result<LogicalPlan> {
368368
match plan {
369-
LogicalPlan::Projection(Projection { schema, alias, .. }) => {
370-
Ok(LogicalPlan::Projection(Projection::try_new_with_schema(
369+
LogicalPlan::Projection(Projection { schema, alias, .. }) => Ok(
370+
LogicalPlan::Projection(Projection::try_new_with_schema_alias(
371371
expr.to_vec(),
372372
Arc::new(inputs[0].clone()),
373373
schema.clone(),
374374
alias.clone(),
375-
)?))
376-
}
375+
)?),
376+
),
377377
LogicalPlan::Values(Values { schema, .. }) => Ok(LogicalPlan::Values(Values {
378378
schema: schema.clone(),
379379
values: expr

datafusion/optimizer/src/common_subexpr_eliminate.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ impl OptimizerRule for CommonSubexprEliminate {
114114
optimizer_config,
115115
)?;
116116

117-
Ok(LogicalPlan::Projection(Projection::try_new_with_schema(
118-
pop_expr(&mut new_expr)?,
119-
Arc::new(new_input),
120-
schema.clone(),
121-
alias.clone(),
122-
)?))
117+
Ok(LogicalPlan::Projection(
118+
Projection::try_new_with_schema_alias(
119+
pop_expr(&mut new_expr)?,
120+
Arc::new(new_input),
121+
schema.clone(),
122+
alias.clone(),
123+
)?,
124+
))
123125
}
124126
LogicalPlan::Filter(filter) => {
125127
let input = filter.input();
@@ -328,7 +330,6 @@ fn build_project_plan(
328330
project_exprs,
329331
Arc::new(input),
330332
Arc::new(schema),
331-
None,
332333
)?))
333334
}
334335

datafusion/optimizer/src/limit_push_down.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,19 @@ fn limit_push_down(
160160
ancestor,
161161
) => {
162162
// Push down limit directly (projection doesn't change number of rows)
163-
Ok(LogicalPlan::Projection(Projection::try_new_with_schema(
164-
expr.clone(),
165-
Arc::new(limit_push_down(
166-
_optimizer,
167-
ancestor,
168-
input.as_ref(),
169-
_optimizer_config,
170-
)?),
171-
schema.clone(),
172-
alias.clone(),
173-
)?))
163+
Ok(LogicalPlan::Projection(
164+
Projection::try_new_with_schema_alias(
165+
expr.clone(),
166+
Arc::new(limit_push_down(
167+
_optimizer,
168+
ancestor,
169+
input.as_ref(),
170+
_optimizer_config,
171+
)?),
172+
schema.clone(),
173+
alias.clone(),
174+
)?,
175+
))
174176
}
175177
(
176178
LogicalPlan::Union(Union { inputs, schema }),

datafusion/optimizer/src/projection_push_down.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,16 @@ fn optimize_plan(
192192
Ok(new_input)
193193
} else {
194194
let metadata = new_input.schema().metadata().clone();
195-
Ok(LogicalPlan::Projection(Projection::try_new_with_schema(
196-
new_expr,
197-
Arc::new(new_input),
198-
DFSchemaRef::new(DFSchema::new_with_metadata(new_fields, metadata)?),
199-
alias.clone(),
200-
)?))
195+
Ok(LogicalPlan::Projection(
196+
Projection::try_new_with_schema_alias(
197+
new_expr,
198+
Arc::new(new_input),
199+
DFSchemaRef::new(DFSchema::new_with_metadata(
200+
new_fields, metadata,
201+
)?),
202+
alias.clone(),
203+
)?,
204+
))
201205
}
202206
}
203207
LogicalPlan::Join(Join {
@@ -836,11 +840,8 @@ mod tests {
836840
// that the Column references are unqualified (e.g. their
837841
// relation is `None`). PlanBuilder resolves the expressions
838842
let expr = vec![col("a"), col("b")];
839-
let plan = LogicalPlan::Projection(Projection::try_new(
840-
expr,
841-
Arc::new(table_scan),
842-
None,
843-
)?);
843+
let plan =
844+
LogicalPlan::Projection(Projection::try_new(expr, Arc::new(table_scan))?);
844845

845846
assert_fields_eq(&plan, vec!["a", "b"]);
846847

datafusion/optimizer/src/propagate_empty_relation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ impl OptimizerRule for PropagateEmptyRelation {
120120
Ok(LogicalPlan::Projection(Projection::new_from_schema(
121121
Arc::new(child),
122122
optimized_children_plan.schema().clone(),
123-
None,
124123
)))
125124
}
126125
} else {

datafusion/optimizer/src/single_distinct_to_groupby.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ impl OptimizerRule for SingleDistinctToGroupBy {
196196
alias_expr,
197197
Arc::new(outer_aggr),
198198
schema.clone(),
199-
None,
200199
)?))
201200
} else {
202201
utils::optimize_children(self, plan, _optimizer_config)

0 commit comments

Comments
 (0)