@@ -23,14 +23,25 @@ use crate::serde::protobuf::action::ActionType;
23
23
use crate :: serde:: scheduler:: {
24
24
Action , ExecutePartition , PartitionId , PartitionLocation , PartitionStats ,
25
25
} ;
26
+ use datafusion:: physical_plan:: Partitioning ;
26
27
27
28
impl TryInto < protobuf:: Action > for Action {
28
29
type Error = BallistaError ;
29
30
30
31
fn try_into ( self ) -> Result < protobuf:: Action , Self :: Error > {
31
32
match self {
32
- Action :: FetchPartition ( partition_id) => Ok ( protobuf:: Action {
33
- action_type : Some ( ActionType :: FetchPartition ( partition_id. into ( ) ) ) ,
33
+ Action :: FetchPartition {
34
+ job_id,
35
+ stage_id,
36
+ partition_id,
37
+ path,
38
+ } => Ok ( protobuf:: Action {
39
+ action_type : Some ( ActionType :: FetchPartition ( protobuf:: FetchPartition {
40
+ job_id,
41
+ stage_id : stage_id as u32 ,
42
+ partition_id : partition_id as u32 ,
43
+ path,
44
+ } ) ) ,
34
45
settings : vec ! [ ] ,
35
46
} ) ,
36
47
}
@@ -47,6 +58,9 @@ impl TryInto<protobuf::ExecutePartition> for ExecutePartition {
47
58
partition_id : self . partition_id . iter ( ) . map ( |n| * n as u32 ) . collect ( ) ,
48
59
plan : Some ( self . plan . try_into ( ) ?) ,
49
60
partition_location : vec ! [ ] ,
61
+ output_partitioning : hash_partitioning_to_proto (
62
+ self . output_partitioning . as_ref ( ) ,
63
+ ) ?,
50
64
} )
51
65
}
52
66
}
@@ -87,3 +101,26 @@ impl Into<protobuf::PartitionStats> for PartitionStats {
87
101
}
88
102
}
89
103
}
104
+
105
+ pub fn hash_partitioning_to_proto (
106
+ output_partitioning : Option < & Partitioning > ,
107
+ ) -> Result < Option < protobuf:: PhysicalHashRepartition > , BallistaError > {
108
+ match output_partitioning {
109
+ Some ( Partitioning :: Hash ( exprs, partition_count) ) => {
110
+ Ok ( Some ( protobuf:: PhysicalHashRepartition {
111
+ hash_expr : exprs
112
+ . iter ( )
113
+ . map ( |expr| expr. clone ( ) . try_into ( ) )
114
+ . collect :: < Result < Vec < _ > , BallistaError > > ( ) ?,
115
+ partition_count : * partition_count as u64 ,
116
+ } ) )
117
+ }
118
+ None => Ok ( None ) ,
119
+ other => {
120
+ return Err ( BallistaError :: General ( format ! (
121
+ "scheduler::to_proto() invalid partitioning for ExecutePartition: {:?}" ,
122
+ other
123
+ ) ) )
124
+ }
125
+ }
126
+ }
0 commit comments