@@ -44,96 +44,85 @@ use crate::protobuf::{ConfigOption, PhysicalSortExprNode};
44
44
use datafusion:: logical_expr:: BuiltinScalarFunction ;
45
45
use datafusion:: physical_expr:: expressions:: DateTimeIntervalExpr ;
46
46
use datafusion:: physical_expr:: ScalarFunctionExpr ;
47
+ use datafusion:: physical_plan:: joins:: utils:: JoinSide ;
47
48
use datafusion_common:: DataFusionError ;
48
49
49
- impl TryInto < protobuf :: PhysicalExprNode > for Arc < dyn AggregateExpr > {
50
+ impl TryFrom < Arc < dyn AggregateExpr > > for protobuf :: PhysicalExprNode {
50
51
type Error = DataFusionError ;
51
52
52
- fn try_into ( self ) -> Result < protobuf :: PhysicalExprNode , Self :: Error > {
53
+ fn try_from ( a : Arc < dyn AggregateExpr > ) -> Result < Self , Self :: Error > {
53
54
use datafusion:: physical_plan:: expressions;
54
55
use protobuf:: AggregateFunction ;
55
56
56
57
let mut distinct = false ;
57
- let aggr_function = if self . as_any ( ) . downcast_ref :: < Avg > ( ) . is_some ( ) {
58
+ let aggr_function = if a . as_any ( ) . downcast_ref :: < Avg > ( ) . is_some ( ) {
58
59
Ok ( AggregateFunction :: Avg . into ( ) )
59
- } else if self . as_any ( ) . downcast_ref :: < Sum > ( ) . is_some ( ) {
60
+ } else if a . as_any ( ) . downcast_ref :: < Sum > ( ) . is_some ( ) {
60
61
Ok ( AggregateFunction :: Sum . into ( ) )
61
- } else if self . as_any ( ) . downcast_ref :: < Count > ( ) . is_some ( ) {
62
+ } else if a . as_any ( ) . downcast_ref :: < Count > ( ) . is_some ( ) {
62
63
Ok ( AggregateFunction :: Count . into ( ) )
63
- } else if self . as_any ( ) . downcast_ref :: < DistinctCount > ( ) . is_some ( ) {
64
+ } else if a . as_any ( ) . downcast_ref :: < DistinctCount > ( ) . is_some ( ) {
64
65
distinct = true ;
65
66
Ok ( AggregateFunction :: Count . into ( ) )
66
- } else if self . as_any ( ) . downcast_ref :: < Min > ( ) . is_some ( ) {
67
+ } else if a . as_any ( ) . downcast_ref :: < Min > ( ) . is_some ( ) {
67
68
Ok ( AggregateFunction :: Min . into ( ) )
68
- } else if self . as_any ( ) . downcast_ref :: < Max > ( ) . is_some ( ) {
69
+ } else if a . as_any ( ) . downcast_ref :: < Max > ( ) . is_some ( ) {
69
70
Ok ( AggregateFunction :: Max . into ( ) )
70
- } else if self
71
+ } else if a
71
72
. as_any ( )
72
73
. downcast_ref :: < expressions:: ApproxDistinct > ( )
73
74
. is_some ( )
74
75
{
75
76
Ok ( AggregateFunction :: ApproxDistinct . into ( ) )
76
- } else if self
77
- . as_any ( )
78
- . downcast_ref :: < expressions:: ArrayAgg > ( )
79
- . is_some ( )
80
- {
77
+ } else if a. as_any ( ) . downcast_ref :: < expressions:: ArrayAgg > ( ) . is_some ( ) {
81
78
Ok ( AggregateFunction :: ArrayAgg . into ( ) )
82
- } else if self
83
- . as_any ( )
84
- . downcast_ref :: < expressions:: Variance > ( )
85
- . is_some ( )
86
- {
79
+ } else if a. as_any ( ) . downcast_ref :: < expressions:: Variance > ( ) . is_some ( ) {
87
80
Ok ( AggregateFunction :: Variance . into ( ) )
88
- } else if self
81
+ } else if a
89
82
. as_any ( )
90
83
. downcast_ref :: < expressions:: VariancePop > ( )
91
84
. is_some ( )
92
85
{
93
86
Ok ( AggregateFunction :: VariancePop . into ( ) )
94
- } else if self
87
+ } else if a
95
88
. as_any ( )
96
89
. downcast_ref :: < expressions:: Covariance > ( )
97
90
. is_some ( )
98
91
{
99
92
Ok ( AggregateFunction :: Covariance . into ( ) )
100
- } else if self
93
+ } else if a
101
94
. as_any ( )
102
95
. downcast_ref :: < expressions:: CovariancePop > ( )
103
96
. is_some ( )
104
97
{
105
98
Ok ( AggregateFunction :: CovariancePop . into ( ) )
106
- } else if self
107
- . as_any ( )
108
- . downcast_ref :: < expressions:: Stddev > ( )
109
- . is_some ( )
110
- {
99
+ } else if a. as_any ( ) . downcast_ref :: < expressions:: Stddev > ( ) . is_some ( ) {
111
100
Ok ( AggregateFunction :: Stddev . into ( ) )
112
- } else if self
101
+ } else if a
113
102
. as_any ( )
114
103
. downcast_ref :: < expressions:: StddevPop > ( )
115
104
. is_some ( )
116
105
{
117
106
Ok ( AggregateFunction :: StddevPop . into ( ) )
118
- } else if self
107
+ } else if a
119
108
. as_any ( )
120
109
. downcast_ref :: < expressions:: Correlation > ( )
121
110
. is_some ( )
122
111
{
123
112
Ok ( AggregateFunction :: Correlation . into ( ) )
124
- } else if self
113
+ } else if a
125
114
. as_any ( )
126
115
. downcast_ref :: < expressions:: ApproxPercentileCont > ( )
127
116
. is_some ( )
128
117
{
129
118
Ok ( AggregateFunction :: ApproxPercentileCont . into ( ) )
130
- } else if self
119
+ } else if a
131
120
. as_any ( )
132
121
. downcast_ref :: < expressions:: ApproxPercentileContWithWeight > ( )
133
122
. is_some ( )
134
123
{
135
124
Ok ( AggregateFunction :: ApproxPercentileContWithWeight . into ( ) )
136
- } else if self
125
+ } else if a
137
126
. as_any ( )
138
127
. downcast_ref :: < expressions:: ApproxMedian > ( )
139
128
. is_some ( )
@@ -142,10 +131,10 @@ impl TryInto<protobuf::PhysicalExprNode> for Arc<dyn AggregateExpr> {
142
131
} else {
143
132
Err ( DataFusionError :: NotImplemented ( format ! (
144
133
"Aggregate function not supported: {:?}" ,
145
- self
134
+ a
146
135
) ) )
147
136
} ?;
148
- let expressions: Vec < protobuf:: PhysicalExprNode > = self
137
+ let expressions: Vec < protobuf:: PhysicalExprNode > = a
149
138
. expressions ( )
150
139
. iter ( )
151
140
. map ( |e| e. clone ( ) . try_into ( ) )
@@ -494,15 +483,11 @@ impl TryFrom<&FileScanConfig> for protobuf::FileScanExecConf {
494
483
}
495
484
}
496
485
497
- impl From < datafusion :: physical_plan :: joins :: utils :: JoinSide > for protobuf:: JoinSide {
498
- fn from ( t : datafusion :: physical_plan :: joins :: utils :: JoinSide ) -> Self {
486
+ impl From < JoinSide > for protobuf:: JoinSide {
487
+ fn from ( t : JoinSide ) -> Self {
499
488
match t {
500
- datafusion:: physical_plan:: joins:: utils:: JoinSide :: Left => {
501
- protobuf:: JoinSide :: LeftSide
502
- }
503
- datafusion:: physical_plan:: joins:: utils:: JoinSide :: Right => {
504
- protobuf:: JoinSide :: RightSide
505
- }
489
+ JoinSide :: Left => protobuf:: JoinSide :: LeftSide ,
490
+ JoinSide :: Right => protobuf:: JoinSide :: RightSide ,
506
491
}
507
492
}
508
493
}
0 commit comments