Skip to content

Commit b4858fd

Browse files
authored
feat: add count distinct aggregate function (#1314)
1 parent f240dde commit b4858fd

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/alerts/alerts_utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use arrow_array::{Float64Array, Int64Array, RecordBatch};
2020
use datafusion::{
2121
functions_aggregate::{
22-
count::count,
22+
count::{count, count_distinct},
2323
expr_fn::avg,
2424
min_max::{max, min},
2525
sum::sum,
@@ -387,6 +387,7 @@ fn match_aggregate_operation(agg: &AggregateConfig) -> Expr {
387387
let column = format!(r#""{}""#, agg.column);
388388
match agg.aggregate_function {
389389
AggregateFunction::Avg => avg(col(column)),
390+
AggregateFunction::CountDistinct => count_distinct(col(column)),
390391
AggregateFunction::Count => count(col(column)),
391392
AggregateFunction::Min => min(col(column)),
392393
AggregateFunction::Max => max(col(column)),

src/alerts/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ impl Display for WhereConfigOperator {
290290
pub enum AggregateFunction {
291291
Avg,
292292
Count,
293+
CountDistinct,
293294
Min,
294295
Max,
295296
Sum,
@@ -300,6 +301,7 @@ impl Display for AggregateFunction {
300301
match self {
301302
AggregateFunction::Avg => write!(f, "Avg"),
302303
AggregateFunction::Count => write!(f, "Count"),
304+
AggregateFunction::CountDistinct => write!(f, "CountDistinct"),
303305
AggregateFunction::Min => write!(f, "Min"),
304306
AggregateFunction::Max => write!(f, "Max"),
305307
AggregateFunction::Sum => write!(f, "Sum"),

0 commit comments

Comments
 (0)