Returns the field of the default value(if provided) when the expression is `NULL`. Otherwise, returns the expression field unchanged.
(input_fields: &[FieldRef])
| 370 | /// |
| 371 | /// Otherwise, returns the expression field unchanged. |
| 372 | fn parse_expr_field(input_fields: &[FieldRef]) -> Result<FieldRef> { |
| 373 | assert!(!input_fields.is_empty()); |
| 374 | let expr_field = input_fields.first().unwrap_or(&NULL_FIELD); |
| 375 | |
| 376 | // Handles the most common case where NULL is unexpected |
| 377 | if !expr_field.data_type().is_null() { |
| 378 | return Ok(expr_field.as_ref().clone().with_nullable(true).into()); |
| 379 | } |
| 380 | |
| 381 | let default_value_field = input_fields.get(2).unwrap_or(&NULL_FIELD); |
| 382 | Ok(default_value_field |
| 383 | .as_ref() |
| 384 | .clone() |
| 385 | .with_nullable(true) |
| 386 | .into()) |
| 387 | } |
| 388 | |
| 389 | /// Handles type coercion and null value refinement for default value |
| 390 | /// argument depending on the data type of the input expression. |