Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions datafusion/proto/src/logical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -536,7 +536,8 @@ impl AsLogicalPlan for LogicalPlanNode {
let expr: Vec<Expr> =
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) => {
Expand All @@ -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 =
Expand All @@ -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)?;
Expand Down Expand Up @@ -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;
Expand Down