Skip to content

Commit dd005ff

Browse files
committed
refactor(proto): reuse sink sort encoding
The central sink serializer duplicated DataSinkExec's sort-order encoding, which could let fallback and delegated paths drift. Use the shared helper so both paths produce the same wire data. Refs apache#23498 Signed-off-by: Jiawei Zhao <[email protected]>
1 parent 92fe98b commit dd005ff

1 file changed

Lines changed: 5 additions & 23 deletions

File tree

  • datafusion/proto/src/physical_plan

‎datafusion/proto/src/physical_plan/mod.rs‎

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ use datafusion_physical_plan::coalesce_partitions::CoalescePartitionsExec;
7070
use datafusion_physical_plan::coop::CooperativeExec;
7171
use datafusion_physical_plan::empty::EmptyExec;
7272
use datafusion_physical_plan::explain::ExplainExec;
73-
use datafusion_physical_plan::expressions::PhysicalSortExpr;
7473
use datafusion_physical_plan::filter::FilterExec;
7574
use datafusion_physical_plan::joins::{
7675
CrossJoinExec, HashJoinExec, NestedLoopJoinExec, SortMergeJoinExec,
@@ -2580,29 +2579,12 @@ pub trait PhysicalPlanNodeExt: Sized {
25802579
codec,
25812580
proto_converter,
25822581
)?;
2583-
let sort_order = match exec.sort_order() {
2584-
Some(requirements) => {
2585-
let expr = requirements
2586-
.iter()
2587-
.map(|requirement| {
2588-
let expr: PhysicalSortExpr = requirement.to_owned().into();
2589-
let sort_expr = protobuf::PhysicalSortExprNode {
2590-
expr: Some(Box::new(
2591-
proto_converter
2592-
.physical_expr_to_proto(&expr.expr, codec)?,
2593-
)),
2594-
asc: !expr.options.descending,
2595-
nulls_first: expr.options.nulls_first,
2596-
};
2597-
Ok(sort_expr)
2598-
})
2599-
.collect::<Result<Vec<_>>>()?;
2600-
Some(protobuf::PhysicalSortExprNodeCollection {
2601-
physical_sort_expr_nodes: expr,
2602-
})
2603-
}
2604-
None => None,
2582+
let encoder = ConverterPlanEncoder {
2583+
codec,
2584+
proto_converter,
26052585
};
2586+
let encode_ctx = ExecutionPlanEncodeCtx::new(&encoder);
2587+
let sort_order = exec.encode_sort_order(&encode_ctx)?;
26062588

26072589
if let Some(sink) = exec.sink().downcast_ref::<JsonSink>() {
26082590
return Ok(Some(protobuf::PhysicalPlanNode {

0 commit comments

Comments
 (0)