@@ -35,10 +35,8 @@ use super::AggrState;
3535use super :: AggrStateLoc ;
3636use super :: AggregateCountFunction ;
3737use super :: AggregateFunction ;
38- use super :: AggregateFunctionCombinatorNull ;
3938use super :: AggregateFunctionCreator ;
4039use super :: AggregateFunctionDescription ;
41- use super :: AggregateFunctionFeatures ;
4240use super :: AggregateFunctionSortDesc ;
4341use super :: CombinatorDescription ;
4442use super :: StateAddr ;
@@ -49,32 +47,19 @@ use super::aggregate_distinct_state::AggregateDistinctStringState;
4947use super :: aggregate_distinct_state:: AggregateDistinctTimestampState ;
5048use super :: aggregate_distinct_state:: AggregateUniqStringState ;
5149use super :: aggregate_distinct_state:: DistinctStateFunc ;
52- use super :: aggregate_null_result:: AggregateNullResultFunction ;
5350use super :: assert_variadic_arguments;
51+ use crate :: aggregates:: AggregateFunctionFeatures ;
5452
53+ #[ derive( Clone ) ]
5554pub struct AggregateDistinctCombinator < State > {
5655 name : String ,
5756
5857 nested_name : String ,
5958 arguments : Vec < DataType > ,
60- skip_null : bool ,
6159 nested : Arc < dyn AggregateFunction > ,
6260 _s : PhantomData < fn ( State ) > ,
6361}
6462
65- impl < State > Clone for AggregateDistinctCombinator < State > {
66- fn clone ( & self ) -> Self {
67- Self {
68- name : self . name . clone ( ) ,
69- nested_name : self . nested_name . clone ( ) ,
70- arguments : self . arguments . clone ( ) ,
71- skip_null : self . skip_null ,
72- nested : self . nested . clone ( ) ,
73- _s : PhantomData ,
74- }
75- }
76- }
77-
7863impl < State > AggregateDistinctCombinator < State >
7964where State : Send + ' static
8065{
@@ -122,12 +107,12 @@ where State: DistinctStateFunc
122107 input_rows : usize ,
123108 ) -> Result < ( ) > {
124109 let state = Self :: get_state ( place) ;
125- state. batch_add ( columns, validity, input_rows, self . skip_null )
110+ state. batch_add ( columns, validity, input_rows)
126111 }
127112
128113 fn accumulate_row ( & self , place : AggrState , columns : ProjectedBlock , row : usize ) -> Result < ( ) > {
129114 let state = Self :: get_state ( place) ;
130- state. add ( columns, row, self . skip_null )
115+ state. add ( columns, row)
131116 }
132117
133118 fn serialize_type ( & self ) -> Vec < StateSerdeItem > {
@@ -234,41 +219,6 @@ pub fn aggregate_uniq_desc() -> AggregateFunctionDescription {
234219 )
235220}
236221
237- pub fn aggregate_count_distinct_desc ( ) -> AggregateFunctionDescription {
238- AggregateFunctionDescription :: creator_with_features (
239- Box :: new ( |_, params, arguments, _| {
240- let count_creator = Box :: new ( AggregateCountFunction :: try_create) as _ ;
241- match * arguments {
242- [ DataType :: Nullable ( _) ] => {
243- let new_arguments =
244- AggregateFunctionCombinatorNull :: transform_arguments ( & arguments) ?;
245- let nested = try_create (
246- "count" ,
247- params. clone ( ) ,
248- new_arguments,
249- vec ! [ ] ,
250- & count_creator,
251- ) ?;
252- AggregateFunctionCombinatorNull :: try_create ( params, arguments, nested, true )
253- }
254- ref arguments
255- if !arguments. is_empty ( ) && arguments. iter ( ) . all ( DataType :: is_null) =>
256- {
257- AggregateNullResultFunction :: try_create ( DataType :: Number (
258- NumberDataType :: UInt64 ,
259- ) )
260- }
261- _ => try_create ( "count" , params, arguments, vec ! [ ] , & count_creator) ,
262- }
263- } ) ,
264- AggregateFunctionFeatures {
265- returns_default_when_only_null : true ,
266- keep_nullable : true ,
267- ..Default :: default ( )
268- } ,
269- )
270- }
271-
272222fn try_create (
273223 nested_name : & str ,
274224 params : Vec < Scalar > ,
@@ -293,7 +243,6 @@ fn try_create(
293243 > {
294244 nested_name: nested_name. to_owned( ) ,
295245 arguments,
296- skip_null: false ,
297246 nested,
298247 name,
299248 _s: PhantomData ,
@@ -305,7 +254,6 @@ fn try_create(
305254 > {
306255 nested_name : nested_name. to_owned ( ) ,
307256 arguments,
308- skip_null : false ,
309257 nested,
310258 name,
311259 _s : PhantomData ,
@@ -315,7 +263,6 @@ fn try_create(
315263 > {
316264 nested_name : nested_name. to_owned ( ) ,
317265 arguments,
318- skip_null : false ,
319266 nested,
320267 name,
321268 _s : PhantomData ,
@@ -326,7 +273,6 @@ fn try_create(
326273 > {
327274 name,
328275 arguments,
329- skip_null : false ,
330276 nested,
331277 nested_name : nested_name. to_owned ( ) ,
332278 _s : PhantomData ,
@@ -337,7 +283,6 @@ fn try_create(
337283 > {
338284 nested_name : nested_name. to_owned ( ) ,
339285 arguments,
340- skip_null : false ,
341286 nested,
342287 name,
343288 _s : PhantomData ,
@@ -346,9 +291,6 @@ fn try_create(
346291 AggregateDistinctState ,
347292 > {
348293 nested_name : nested_name. to_owned ( ) ,
349- skip_null : nested_name == "count"
350- && arguments. len ( ) > 1
351- && arguments. iter ( ) . any ( DataType :: is_nullable_or_null) ,
352294 arguments,
353295 nested,
354296 name,
0 commit comments