Skip to content

Commit 7bfcb7b

Browse files
committed
Correct nullability flag
1 parent f799fca commit 7bfcb7b

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

datafusion/expr/src/udwf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ where
280280
/// unimplemented!()
281281
/// }
282282
/// fn field(&self, field_args: WindowUDFFieldArgs) -> Result<Field> {
283-
/// if let Some(DataType::Int32) = field_args.get_input_type(0) {
283+
/// if let Some(DataType::Int32) = field_args.get_input_field(0).map(|f| f.data_type().clone()) {
284284
/// Ok(Field::new(field_args.name(), DataType::Int32, false))
285285
/// } else {
286286
/// plan_err!("smooth_it only accepts Int32 arguments")

datafusion/functions-window/src/lead_lag.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ fn parse_expr_type(input_fields: &[Field]) -> Result<Field> {
303303

304304
// Handles the most common case where NULL is unexpected
305305
if !expr_field.data_type().is_null() {
306-
return Ok(expr_field.clone());
306+
return Ok(expr_field.clone().with_nullable(true));
307307
}
308308

309309
let default_value_field = input_fields.get(2).unwrap_or(&null_field);
310-
Ok(default_value_field.clone())
310+
Ok(default_value_field.clone().with_nullable(true))
311311
}
312312

313313
/// Handles type coercion and null value refinement for default value

datafusion/functions-window/src/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ macro_rules! get_or_init_udwf {
286286
/// # fn field(&self, field_args: WindowUDFFieldArgs) -> datafusion_common::Result<Field> {
287287
/// # Ok(Field::new(
288288
/// # field_args.name(),
289-
/// # field_args.get_input_type(0).unwrap(),
289+
/// # field_args.get_input_field(0).unwrap().data_type().clone(),
290290
/// # false,
291291
/// # ))
292292
/// # }
@@ -557,7 +557,7 @@ macro_rules! create_udwf_expr {
557557
/// # fn field(&self, field_args: WindowUDFFieldArgs) -> datafusion_common::Result<Field> {
558558
/// # Ok(Field::new(
559559
/// # field_args.name(),
560-
/// # field_args.get_input_type(0).unwrap(),
560+
/// # field_args.get_input_field(0).unwrap().data_type().clone(),
561561
/// # false,
562562
/// # ))
563563
/// # }
@@ -646,7 +646,7 @@ macro_rules! create_udwf_expr {
646646
/// # fn field(&self, field_args: WindowUDFFieldArgs) -> datafusion_common::Result<Field> {
647647
/// # Ok(Field::new(
648648
/// # field_args.name(),
649-
/// # field_args.get_input_type(0).unwrap(),
649+
/// # field_args.get_input_field(0).unwrap().data_type().clone(),
650650
/// # false,
651651
/// # ))
652652
/// # }

datafusion/functions-window/src/nth_value.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,14 @@ impl WindowUDFImpl for NthValue {
270270
}
271271

272272
fn field(&self, field_args: WindowUDFFieldArgs) -> Result<Field> {
273-
let return_field = field_args
273+
let return_type = field_args
274274
.input_fields()
275275
.first()
276+
.map(|f| f.data_type())
276277
.cloned()
277-
.unwrap_or(Field::new("f", DataType::Null, true));
278+
.unwrap_or(DataType::Null);
278279

279-
Ok(return_field.with_name(field_args.name()))
280+
Ok(Field::new(field_args.name(), return_type, true))
280281
}
281282

282283
fn reverse_expr(&self) -> ReversedUDWF {

0 commit comments

Comments
 (0)