Skip to content

Commit c93fc81

Browse files
committed
cover type coercion changing lambda parameters in existing sqlintegration test
1 parent f1653c8 commit c93fc81

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

datafusion/sql/tests/sql_integration.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5342,15 +5342,17 @@ fn test_progressive_lambda_parameters() {
53425342
.unwrap()
53435343
.unwrap();
53445344

5345-
// test that merge accumulator parameter and finish parameter correctly
5346-
// got the type of the merge lambda output (Float64), and not the initial value type (Int64)
5345+
// taking into account the user defined coercion that coerced the List(Float64) to List(Float32),
5346+
// test that merge accumulator parameter and finish parameter correctly got the type of the merge
5347+
// lambda output (Float32 instead of Float64), and not the initial value type (Int64)
53475348
assert_eq!(
53485349
expr,
53495350
Expr::HigherOrderFunction(HigherOrderFunction::new(
53505351
Arc::new(MockArrayReduce::new()),
53515352
vec![
53525353
Expr::ScalarFunction(ScalarFunction::new_udf(
53535354
make_array_udf(),
5355+
// note the array being reduced is List(Float64)
53545356
vec![
53555357
Expr::Literal(1.0f64.into(), None),
53565358
Expr::Literal(2.0f64.into(), None)
@@ -5359,10 +5361,11 @@ fn test_progressive_lambda_parameters() {
53595361
Expr::Literal(0i64.into(), None),
53605362
lambda(
53615363
["acc", "v"],
5362-
resolved_lambda_var("acc", DataType::Float64)
5363-
+ resolved_lambda_var("v", DataType::Float64)
5364+
// lambda vars are Float32
5365+
resolved_lambda_var("acc", DataType::Float32)
5366+
+ resolved_lambda_var("v", DataType::Float32)
53645367
),
5365-
lambda(["v"], -resolved_lambda_var("v", DataType::Float64)),
5368+
lambda(["v"], -resolved_lambda_var("v", DataType::Float32)),
53665369
]
53675370
))
53685371
)
@@ -5384,7 +5387,7 @@ impl MockArrayReduce {
53845387
#[expect(clippy::new_without_default)]
53855388
pub fn new() -> Self {
53865389
Self {
5387-
signature: HigherOrderSignature::variadic_any(Volatility::Immutable),
5390+
signature: HigherOrderSignature::user_defined(Volatility::Immutable),
53885391
}
53895392
}
53905393
}
@@ -5402,6 +5405,17 @@ impl HigherOrderUDF for MockArrayReduce {
54025405
&self.signature
54035406
}
54045407

5408+
fn coerce_value_types(&self, arg_types: &[DataType]) -> Result<Vec<DataType>> {
5409+
let [_list, initial] = arg_types else {
5410+
unreachable!()
5411+
};
5412+
5413+
Ok(vec![
5414+
DataType::new_list(DataType::Float32, true),
5415+
initial.clone(),
5416+
])
5417+
}
5418+
54055419
fn lambda_parameters(
54065420
&self,
54075421
step: usize,

0 commit comments

Comments
 (0)