diff --git a/datafusion/proto/src/logical_plan/mod.rs b/datafusion/proto/src/logical_plan/mod.rs index 37b42fc9a3bab..58c77542b44ec 100644 --- a/datafusion/proto/src/logical_plan/mod.rs +++ b/datafusion/proto/src/logical_plan/mod.rs @@ -68,8 +68,8 @@ use datafusion_expr::{ logical_plan::{ Aggregate, AsOfJoin, AsOfMatch, CreateCatalog, CreateCatalogSchema, CreateExternalTable, CreateView, DdlStatement, Distinct, EmptyRelation, - Extension, Join, Prepare, Projection, Repartition, Sort, SubqueryAlias, - TableScan, TableScanBuilder, Values, Window, builder::project, + Extension, Filter, Join, Prepare, Projection, Repartition, Sort, SubqueryAlias, + TableScan, TableScanBuilder, Values, Window, }, }; use datafusion_proto_common::protobuf_common; @@ -536,7 +536,8 @@ impl AsLogicalPlan for LogicalPlanNode { let expr: Vec = from_proto::parse_exprs(&projection.expr, ctx, extension_codec)?; - let new_proj = project(input, expr)?; + let new_proj = + LogicalPlan::Projection(Projection::try_new(expr, Arc::new(input))?); match projection.optional_alias.as_ref() { Some(a) => match a { protobuf::projection_node::OptionalAlias::Alias(alias) => { @@ -558,14 +559,17 @@ impl AsLogicalPlan for LogicalPlanNode { .map(|expr| from_proto::parse_expr(expr, ctx, extension_codec)) .transpose()? .ok_or_else(|| proto_error("expression required"))?; - LogicalPlanBuilder::from(input).filter(expr)?.build() + Ok(LogicalPlan::Filter(Filter::try_new(expr, Arc::new(input))?)) } LogicalPlanType::Window(window) => { let input: LogicalPlan = into_logical_plan!(window.input, ctx, extension_codec)?; let window_expr = from_proto::parse_exprs(&window.window_expr, ctx, extension_codec)?; - LogicalPlanBuilder::from(input).window(window_expr)?.build() + Ok(LogicalPlan::Window(Window::try_new( + window_expr, + Arc::new(input), + )?)) } LogicalPlanType::Aggregate(aggregate) => { let input: LogicalPlan = @@ -574,9 +578,11 @@ impl AsLogicalPlan for LogicalPlanNode { from_proto::parse_exprs(&aggregate.group_expr, ctx, extension_codec)?; let aggr_expr = from_proto::parse_exprs(&aggregate.aggr_expr, ctx, extension_codec)?; - LogicalPlanBuilder::from(input) - .aggregate(group_expr, aggr_expr)? - .build() + Ok(LogicalPlan::Aggregate(Aggregate::try_new( + Arc::new(input), + group_expr, + aggr_expr, + )?)) } LogicalPlanType::ListingScan(scan) => { let schema: Schema = convert_required!(scan.schema)?; @@ -746,9 +752,11 @@ impl AsLogicalPlan for LogicalPlanNode { let fetch = (sort.fetch >= 0) .then(|| usize_from_wire(sort.fetch, "Sort", "fetch")) .transpose()?; - LogicalPlanBuilder::from(input) - .sort_with_limit(sort_expr, fetch)? - .build() + Ok(LogicalPlan::Sort(Sort { + expr: sort_expr, + input: Arc::new(input), + fetch, + })) } LogicalPlanType::Repartition(repartition) => { use datafusion_expr::Partitioning;