@@ -688,11 +688,37 @@ impl ExecutionPlan for PiecewiseMergeJoinExec {
688688 ) -> Result < Option < datafusion_proto_models:: protobuf:: PhysicalPlanNode > > {
689689 use datafusion_proto_models:: protobuf;
690690
691- let buffered = ctx. encode_child ( self . buffered ( ) ) ?;
692- let streamed = ctx. encode_child ( self . streamed ( ) ) ?;
693- let on_buffered = ctx. encode_expr ( & self . on . 0 ) ?;
694- let on_streamed = ctx. encode_expr ( & self . on . 1 ) ?;
695- let join_type = crate :: joins:: proto:: join_type_to_proto ( self . join_type ( ) ) ;
691+ // Destructure exhaustively (no `..`) so that a newly added field is a
692+ // compile error here instead of being silently left out of the proto.
693+ let Self {
694+ buffered,
695+ streamed,
696+ on,
697+ operator,
698+ join_type,
699+ num_partitions,
700+ // derived from the children's schemas by `try_new` on decode
701+ schema : _,
702+ // buffered side collected at execution time, not part of the plan
703+ buffered_fut : _,
704+ // runtime metrics, not part of the plan
705+ metrics : _,
706+ // recomputed from `on` and `sort_options` by `try_new` on decode
707+ left_child_plan_required_order : _,
708+ // recomputed from `on` and `sort_options` by `try_new` on decode
709+ right_batch_required_orders : _,
710+ // recomputed from `operator` and `join_type` by `try_new` on decode
711+ sort_options : _,
712+ // recomputed by `try_new` on decode
713+ cache : _,
714+ } = self ;
715+
716+ let ( on_buffered, on_streamed) = on;
717+ let buffered = ctx. encode_child ( buffered) ?;
718+ let streamed = ctx. encode_child ( streamed) ?;
719+ let on_buffered = ctx. encode_expr ( on_buffered) ?;
720+ let on_streamed = ctx. encode_expr ( on_streamed) ?;
721+ let join_type = crate :: joins:: proto:: join_type_to_proto ( * join_type) ;
696722
697723 Ok ( Some ( protobuf:: PhysicalPlanNode {
698724 physical_plan_type : Some (
@@ -704,9 +730,9 @@ impl ExecutionPlan for PiecewiseMergeJoinExec {
704730 on_streamed : Some ( on_streamed) ,
705731 // Matches the `Operator` encoding used for `BinaryExpr`:
706732 // the `Debug` name of the variant.
707- operator : format ! ( "{:?}" , self . operator ) ,
733+ operator : format ! ( "{operator :?}" ) ,
708734 join_type : join_type. into ( ) ,
709- num_partitions : self . num_partitions as u64 ,
735+ num_partitions : * num_partitions as u64 ,
710736 } ) ,
711737 ) ,
712738 ) ,
@@ -735,47 +761,57 @@ impl PiecewiseMergeJoinExec {
735761 protobuf:: physical_plan_node:: PhysicalPlanType :: PiecewiseMergeJoin ,
736762 "PiecewiseMergeJoinExec" ,
737763 ) ;
764+ // Destructure exhaustively (no `..`) so that a newly added proto field
765+ // is a compile error here instead of being silently ignored.
766+ let protobuf:: PiecewiseMergeJoinExecNode {
767+ buffered,
768+ streamed,
769+ on_buffered,
770+ on_streamed,
771+ operator,
772+ join_type,
773+ num_partitions,
774+ } = & * * join;
775+
738776 let buffered = ctx. decode_required_child (
739- join . buffered . as_deref ( ) ,
777+ buffered. as_deref ( ) ,
740778 "PiecewiseMergeJoinExec" ,
741779 "buffered" ,
742780 ) ?;
743781 let streamed = ctx. decode_required_child (
744- join . streamed . as_deref ( ) ,
782+ streamed. as_deref ( ) ,
745783 "PiecewiseMergeJoinExec" ,
746784 "streamed" ,
747785 ) ?;
748786 let on_buffered = ctx. decode_required_expr (
749- join . on_buffered . as_ref ( ) ,
787+ on_buffered. as_ref ( ) ,
750788 buffered. schema ( ) . as_ref ( ) ,
751789 "PiecewiseMergeJoinExec" ,
752790 "on_buffered" ,
753791 ) ?;
754792 let on_streamed = ctx. decode_required_expr (
755- join . on_streamed . as_ref ( ) ,
793+ on_streamed. as_ref ( ) ,
756794 streamed. schema ( ) . as_ref ( ) ,
757795 "PiecewiseMergeJoinExec" ,
758796 "on_streamed" ,
759797 ) ?;
760798
761- let operator = Operator :: from_proto_name ( & join . operator ) . ok_or_else ( || {
799+ let operator = Operator :: from_proto_name ( operator) . ok_or_else ( || {
762800 internal_datafusion_err ! (
763- "PiecewiseMergeJoinExec: unknown Operator '{}'" ,
764- join. operator
801+ "PiecewiseMergeJoinExec: unknown Operator '{operator}'"
765802 )
766803 } ) ?;
767804 let join_type = crate :: joins:: proto:: join_type_from_proto (
768- join . join_type ,
805+ * join_type,
769806 "PiecewiseMergeJoinExec" ,
770807 ) ?;
771808
772809 // Checked rather than `as usize`: a truncated partition count would not
773810 // fail loudly, it would silently change how the buffered side is split.
774811 let num_partitions =
775- usize:: try_from ( join . num_partitions ) . map_err ( |_| {
812+ usize:: try_from ( * num_partitions) . map_err ( |_| {
776813 plan_datafusion_err ! (
777- "PiecewiseMergeJoinExec: num_partitions {} cannot be represented as usize on this target" ,
778- join. num_partitions
814+ "PiecewiseMergeJoinExec: num_partitions {num_partitions} cannot be represented as usize on this target"
779815 )
780816 } ) ?;
781817
0 commit comments