File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
datafusion/functions-window/src Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -292,21 +292,23 @@ fn parse_expr(
292292 } )
293293}
294294
295+ static NULL_FIELD : LazyLock < Field > =
296+ LazyLock :: new ( || Field :: new ( "value" , DataType :: Null , true ) ) ;
297+
295298/// Returns the field of the default value(if provided) when the
296299/// expression is `NULL`.
297300///
298301/// Otherwise, returns the expression field unchanged.
299302fn parse_expr_field ( input_fields : & [ Field ] ) -> Result < Field > {
300303 assert ! ( !input_fields. is_empty( ) ) ;
301- let null_field = Field :: new ( "value" , DataType :: Null , true ) ;
302- let expr_field = input_fields. first ( ) . unwrap_or ( & null_field) ;
304+ let expr_field = input_fields. first ( ) . unwrap_or ( & NULL_FIELD ) ;
303305
304306 // Handles the most common case where NULL is unexpected
305307 if !expr_field. data_type ( ) . is_null ( ) {
306308 return Ok ( expr_field. clone ( ) . with_nullable ( true ) ) ;
307309 }
308310
309- let default_value_field = input_fields. get ( 2 ) . unwrap_or ( & null_field ) ;
311+ let default_value_field = input_fields. get ( 2 ) . unwrap_or ( & NULL_FIELD ) ;
310312 Ok ( default_value_field. clone ( ) . with_nullable ( true ) )
311313}
312314
You can’t perform that action at this time.
0 commit comments