Skip to content

Commit

Permalink
reject ApproxCountDistinct with DISTINCT
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Chien <stdrc@outlook.com>
  • Loading branch information
stdrc committed Jul 10, 2023
1 parent 09dc684 commit 0ce444f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/frontend/src/binder/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,6 @@ impl Binder {
.map(|arg| self.bind_function_arg(arg.clone()))
.flatten_ok()
.try_collect()?;

if f.distinct && args.is_empty() {
return Err(ErrorCode::InvalidInputSyntax(format!(
"DISTINCT is not allowed for aggregate function `{}` without args",
kind
))
.into());
}

let order_by = OrderBy::new(
f.order_by
.into_iter()
Expand All @@ -353,6 +344,14 @@ impl Binder {
);

if f.distinct {
if kind == AggKind::ApproxCountDistinct {
return Err(ErrorCode::InvalidInputSyntax(format!(
"DISTINCT is not allowed for approximate aggregation `{}`",
kind
))
.into());
}

if args.is_empty() {
return Err(ErrorCode::InvalidInputSyntax(format!(
"DISTINCT is not allowed for aggregate function `{}` without args",
Expand Down

0 comments on commit 0ce444f

Please sign in to comment.