File tree 2 files changed +16
-10
lines changed
2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -46,14 +46,6 @@ impl<'a> Accumulator<'a> {
46
46
target,
47
47
datum : Datum :: Bigint ( 0 ) ,
48
48
} ,
49
- AggregateFunction :: Max => Accumulator {
50
- target,
51
- datum : Datum :: Bigint ( i64:: MIN ) ,
52
- } ,
53
- AggregateFunction :: Min => Accumulator {
54
- target,
55
- datum : Datum :: Bigint ( i64:: MAX ) ,
56
- } ,
57
49
_ => Accumulator {
58
50
target,
59
51
datum : Datum :: Null ,
@@ -68,12 +60,20 @@ impl<'a> Accumulator<'a> {
68
60
match self . target . function ( ) {
69
61
AggregateFunction :: Count => self . datum = self . datum . clone ( ) + column. value ,
70
62
AggregateFunction :: Max => {
71
- if self . datum < column. value {
63
+ if !self . datum . is_null ( ) {
64
+ if self . datum < column. value {
65
+ self . datum = column. value ;
66
+ }
67
+ } else {
72
68
self . datum = column. value ;
73
69
}
74
70
}
75
71
AggregateFunction :: Min => {
76
- if self . datum > column. value {
72
+ if !self . datum . is_null ( ) {
73
+ if self . datum > column. value {
74
+ self . datum = column. value ;
75
+ }
76
+ } else {
77
77
self . datum = column. value ;
78
78
}
79
79
}
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ impl Add for Datum {
78
78
( SmallInt ( a) , SmallInt ( b) ) => SmallInt ( a + b) ,
79
79
( Interval ( a) , Interval ( b) ) => Interval ( a + b) ,
80
80
( Numeric ( a) , Numeric ( b) ) => Numeric ( a + b) ,
81
+ ( Datum :: Null , b) => b,
82
+ ( a, Datum :: Null ) => a,
81
83
_ => Datum :: Null , // Might be good to raise an error.
82
84
}
83
85
}
@@ -103,6 +105,10 @@ impl Datum {
103
105
_ => Ok ( Datum :: Null ) ,
104
106
}
105
107
}
108
+
109
+ pub fn is_null ( & self ) -> bool {
110
+ matches ! ( self , Datum :: Null )
111
+ }
106
112
}
107
113
108
114
/// PostgreSQL data types.
You can’t perform that action at this time.
0 commit comments