Skip to content

Commit

Permalink
Add a unit test for percentile signature error message
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 committed Jan 14, 2024
1 parent 9166a6d commit 6b794b5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion datafusion/optimizer/src/analyzer/type_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ mod test {
}

#[test]
fn agg_function_invalid_input() -> Result<()> {
fn agg_function_invalid_input_avg() -> Result<()> {
let empty = empty();
let fun: AggregateFunction = AggregateFunction::Avg;
let agg_expr = Expr::AggregateFunction(expr::AggregateFunction::new(
Expand All @@ -984,6 +984,30 @@ mod test {
Ok(())
}

#[test]
fn agg_function_invalid_input_percentile() {
let empty = empty();
let fun: AggregateFunction = AggregateFunction::ApproxPercentileCont;
let agg_expr = Expr::AggregateFunction(expr::AggregateFunction::new(
fun,
vec![lit(0.95), lit(42.0), lit(100.0)],
false,
None,
None,
));

let err = Projection::try_new(vec![agg_expr], empty)
.err()
.unwrap()
.strip_backtrace();

let prefix = "Error during planning: No function matches the given name and argument types 'APPROX_PERCENTILE_CONT(Float64, Float64, Float64)'. You might need to add explicit type casts.\n\tCandidate functions:";
assert!(!err
.strip_prefix(prefix)
.unwrap()
.contains("APPROX_PERCENTILE_CONT(Float64, Float64, Float64)"));
}

#[test]
fn binary_op_date32_op_interval() -> Result<()> {
//CAST(Utf8("1998-03-18") AS Date32) + IntervalDayTime("386547056640")
Expand Down

0 comments on commit 6b794b5

Please sign in to comment.