Skip to content

Commit

Permalink
Mark ARRAY_AGG(DISTINCT ...) not implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
James Katz authored and James Katz committed Jan 9, 2022
1 parent 8949bc3 commit 33a5b1a
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion datafusion/src/physical_plan/aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,16 @@ pub fn create_aggregate_expr(
coerced_exprs_types[0].clone(),
))
}
(AggregateFunction::ArrayAgg, _) => Arc::new(expressions::ArrayAgg::new(
(AggregateFunction::ArrayAgg, false) => Arc::new(expressions::ArrayAgg::new(
coerced_phy_exprs[0].clone(),
name,
coerced_exprs_types[0].clone(),
)),
(AggregateFunction::ArrayAgg, true) => {
return Err(DataFusionError::NotImplemented(
"ARRAY_AGG(DISTINCT) aggregations are not available".to_string(),
));
}
(AggregateFunction::Min, _) => Arc::new(expressions::Min::new(
coerced_phy_exprs[0].clone(),
name,
Expand Down Expand Up @@ -265,7 +270,9 @@ pub fn signature(fun: &AggregateFunction) -> Signature {
#[cfg(test)]
mod tests {
use super::*;
use crate::error::DataFusionError::NotImplemented;
use crate::error::Result;
use crate::physical_plan::distinct_expressions::DistinctCount;
use crate::physical_plan::expressions::{
ApproxDistinct, ArrayAgg, Avg, Count, Max, Min, Sum,
};
Expand Down Expand Up @@ -334,6 +341,51 @@ mod tests {
}
_ => {}
};

let result_distinct = create_aggregate_expr(
&fun,
true,
&input_phy_exprs[0..1],
&input_schema,
"c1",
);
match fun {
AggregateFunction::Count => {
let result_agg_phy_exprs_distinct = result_distinct?;
assert!(result_agg_phy_exprs_distinct
.as_any()
.is::<DistinctCount>());
assert_eq!("c1", result_agg_phy_exprs_distinct.name());
assert_eq!(
Field::new("c1", DataType::UInt64, true),
result_agg_phy_exprs_distinct.field().unwrap()
);
}
AggregateFunction::ApproxDistinct => {
let result_agg_phy_exprs_distinct = result_distinct?;
assert!(result_agg_phy_exprs_distinct
.as_any()
.is::<ApproxDistinct>());
assert_eq!("c1", result_agg_phy_exprs_distinct.name());
assert_eq!(
Field::new("c1", DataType::UInt64, false),
result_agg_phy_exprs_distinct.field().unwrap()
);
}
AggregateFunction::ArrayAgg => match result_distinct {
Err(NotImplemented(s)) => {
assert_eq!(
s,
"ARRAY_AGG(DISTINCT) aggregations are not available"
.to_string()
);
}
_ => {
unreachable!()
}
},
_ => {}
};
}
}
Ok(())
Expand Down

0 comments on commit 33a5b1a

Please sign in to comment.