coderfender commented on code in PR #21453:
URL: https://github.com/apache/datafusion/pull/21453#discussion_r3106137119
##########
datafusion/functions-aggregate/src/approx_distinct.rs:
##########
@@ -316,40 +382,39 @@ impl AggregateUDFImpl for ApproxDistinct {
}
fn state_fields(&self, args: StateFieldsArgs) -> Result<Vec<FieldRef>> {
- if args.input_fields[0].data_type().is_null() {
- Ok(vec![
+ let data_type = args.input_fields[0].data_type();
+ match data_type {
+ DataType::Null => Ok(vec![
Field::new(
format_state_name(args.name, self.name()),
DataType::Null,
true,
)
.into(),
- ])
- } else {
- Ok(vec![
+ ]),
+ DataType::UInt8 | DataType::Int8 | DataType::UInt16 |
DataType::Int16 => {
+ get_small_int_state_field(args.name, data_type)
+ }
+ _ => Ok(vec![
Field::new(
format_state_name(args.name, "hll_registers"),
DataType::Binary,
false,
)
.into(),
- ])
+ ]),
}
}
fn accumulator(&self, acc_args: AccumulatorArgs) -> Result<Box<dyn
Accumulator>> {
let data_type = acc_args.expr_fields[0].data_type();
let accumulator: Box<dyn Accumulator> = match data_type {
- // TODO u8, i8, u16, i16 shall really be done using bitmap, not HLL
- // TODO support for boolean (trivial case)
Review Comment:
Yup I moved the Boolean accumulator in a new branch and plan to raise a PR
once this is merged . Thank you @Jefffrey
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]