Skip to content

Commit

Permalink
Minor: make SubqueryAlias::try_new take Arc<LogicalPlan> (#8542)
Browse files Browse the repository at this point in the history
Currently, all `#[non_exhaustive]` logical plan structs with a `try_new`
constructor take `Arc<LogicalPlan>` as parameter, except for
`SubqueryAlias`, which takes a `LogicalPlan`. This changes
`SubqueryAlias::try_new` to align with the other plan types, to improve API
ergonomics.
  • Loading branch information
sadboy authored Dec 15, 2023
1 parent 5a24ec9 commit b457f2b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion datafusion/expr/src/logical_plan/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ pub fn subquery_alias(
plan: LogicalPlan,
alias: impl Into<OwnedTableReference>,
) -> Result<LogicalPlan> {
SubqueryAlias::try_new(plan, alias).map(LogicalPlan::SubqueryAlias)
SubqueryAlias::try_new(Arc::new(plan), alias).map(LogicalPlan::SubqueryAlias)
}

/// Create a LogicalPlanBuilder representing a scan of a table with the provided name and schema.
Expand Down
6 changes: 3 additions & 3 deletions datafusion/expr/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ impl LogicalPlan {
}))
}
LogicalPlan::SubqueryAlias(SubqueryAlias { alias, .. }) => {
SubqueryAlias::try_new(inputs[0].clone(), alias.clone())
SubqueryAlias::try_new(Arc::new(inputs[0].clone()), alias.clone())
.map(LogicalPlan::SubqueryAlias)
}
LogicalPlan::Limit(Limit { skip, fetch, .. }) => {
Expand Down Expand Up @@ -1855,7 +1855,7 @@ pub struct SubqueryAlias {

impl SubqueryAlias {
pub fn try_new(
plan: LogicalPlan,
plan: Arc<LogicalPlan>,
alias: impl Into<OwnedTableReference>,
) -> Result<Self> {
let alias = alias.into();
Expand All @@ -1868,7 +1868,7 @@ impl SubqueryAlias {
.with_functional_dependencies(func_dependencies)?,
);
Ok(SubqueryAlias {
input: Arc::new(plan),
input: plan,
alias,
schema,
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/proto/src/logical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl AsLogicalPlan for LogicalPlanNode {
Some(a) => match a {
protobuf::projection_node::OptionalAlias::Alias(alias) => {
Ok(LogicalPlan::SubqueryAlias(SubqueryAlias::try_new(
new_proj,
Arc::new(new_proj),
alias.clone(),
)?))
}
Expand Down

0 comments on commit b457f2b

Please sign in to comment.