-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: support Boolean in approx_distinct #22707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
440e0b3
c08fb26
4b0c8a8
06d53ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ use datafusion_expr::{ | |
| use datafusion_functions_aggregate_common::aggregate::count_distinct::{ | ||
| Bitmap65536DistinctCountAccumulator, Bitmap65536DistinctCountAccumulatorI16, | ||
| BoolArray256DistinctCountAccumulator, BoolArray256DistinctCountAccumulatorI8, | ||
| BooleanDistinctCountAccumulator, | ||
| }; | ||
| use datafusion_functions_aggregate_common::noop_accumulator::NoopAccumulator; | ||
| use datafusion_macros::user_doc; | ||
|
|
@@ -336,10 +337,13 @@ impl ApproxDistinct { | |
| } | ||
|
|
||
| #[cold] | ||
| fn get_small_int_approx_accumulator( | ||
| fn get_fixed_domain_approx_accumulator( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious why the name
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because the keeping the name |
||
| data_type: &DataType, | ||
| ) -> Result<Box<dyn Accumulator>> { | ||
| match data_type { | ||
| DataType::Boolean => Ok(Box::new(ApproxDistinctBitmapWrapper { | ||
| inner: BooleanDistinctCountAccumulator::new(), | ||
| })), | ||
| DataType::UInt8 => Ok(Box::new(ApproxDistinctBitmapWrapper { | ||
| inner: BoolArray256DistinctCountAccumulator::new(), | ||
| })), | ||
|
|
@@ -357,7 +361,10 @@ fn get_small_int_approx_accumulator( | |
| } | ||
|
|
||
| #[cold] | ||
| fn get_small_int_state_field(name: &str, data_type: &DataType) -> Result<Vec<FieldRef>> { | ||
| fn get_fixed_domain_state_field( | ||
| name: &str, | ||
| data_type: &DataType, | ||
| ) -> Result<Vec<FieldRef>> { | ||
| Ok(vec![ | ||
| Field::new_list( | ||
| format_state_name(name, "approx_distinct"), | ||
|
|
@@ -392,9 +399,11 @@ impl AggregateUDFImpl for ApproxDistinct { | |
| ) | ||
| .into(), | ||
| ]), | ||
| DataType::UInt8 | DataType::Int8 | DataType::UInt16 | DataType::Int16 => { | ||
| get_small_int_state_field(args.name, data_type) | ||
| } | ||
| DataType::Boolean | ||
| | DataType::UInt8 | ||
| | DataType::Int8 | ||
| | DataType::UInt16 | ||
| | DataType::Int16 => get_fixed_domain_state_field(args.name, data_type), | ||
| _ => Ok(vec![ | ||
| Field::new( | ||
| format_state_name(args.name, "hll_registers"), | ||
|
|
@@ -410,8 +419,12 @@ impl AggregateUDFImpl for ApproxDistinct { | |
| let data_type = acc_args.expr_fields[0].data_type(); | ||
|
|
||
| let accumulator: Box<dyn Accumulator> = match data_type { | ||
| DataType::UInt8 | DataType::Int8 | DataType::UInt16 | DataType::Int16 => { | ||
| return get_small_int_approx_accumulator(data_type); | ||
| DataType::Boolean | ||
| | DataType::UInt8 | ||
| | DataType::Int8 | ||
| | DataType::UInt16 | ||
| | DataType::Int16 => { | ||
| return get_fixed_domain_approx_accumulator(data_type); | ||
| } | ||
| DataType::UInt32 => Box::new(NumericHLLAccumulator::<UInt32Type>::new()), | ||
| DataType::UInt64 => Box::new(NumericHLLAccumulator::<UInt64Type>::new()), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.