@@ -50,8 +50,8 @@ use arrow::compute::{cast, concat};
5050use arrow:: datatypes:: { DataType , Field , Schema , SchemaRef } ;
5151use datafusion_common:: config:: { CsvOptions , JsonOptions } ;
5252use datafusion_common:: {
53- exec_err, not_impl_err, plan_err, Column , DFSchema , DataFusionError , ParamValues ,
54- ScalarValue , SchemaError , UnnestOptions ,
53+ exec_err, not_impl_err, plan_datafusion_err , plan_err, Column , DFSchema ,
54+ DataFusionError , ParamValues , ScalarValue , SchemaError , UnnestOptions ,
5555} ;
5656use datafusion_expr:: {
5757 case,
@@ -1932,26 +1932,26 @@ impl DataFrame {
19321932 }
19331933
19341934 /// Fill null values in specified columns with a given value
1935- /// If no columns are specified, applies to all columns
1935+ /// If no columns are specified (empty vector) , applies to all columns
19361936 /// Only fills if the value can be cast to the column's type
19371937 ///
19381938 /// # Arguments
19391939 /// * `value` - Value to fill nulls with
1940- /// * `columns` - Optional list of column names to fill. If None , fills all columns
1940+ /// * `columns` - List of column names to fill. If empty , fills all columns
19411941 pub fn fill_null (
19421942 & self ,
19431943 value : ScalarValue ,
1944- columns : Option < Vec < String > > ,
1944+ columns : Vec < String > ,
19451945 ) -> Result < DataFrame > {
1946- let cols = match columns {
1947- Some ( names) => self . find_columns ( & names) ?,
1948- None => self
1949- . logical_plan ( )
1946+ let cols = if columns. is_empty ( ) {
1947+ self . logical_plan ( )
19501948 . schema ( )
19511949 . fields ( )
19521950 . iter ( )
19531951 . map ( |f| f. as_ref ( ) . clone ( ) )
1954- . collect ( ) ,
1952+ . collect ( )
1953+ } else {
1954+ self . find_columns ( & columns) ?
19551955 } ;
19561956
19571957 // Create projections for each column
@@ -1989,9 +1989,10 @@ impl DataFrame {
19891989 names
19901990 . iter ( )
19911991 . map ( |name| {
1992- schema. field_with_name ( None , name) . cloned ( ) . map_err ( |_| {
1993- DataFusionError :: Plan ( format ! ( "Column '{}' not found" , name) )
1994- } )
1992+ schema
1993+ . field_with_name ( None , name)
1994+ . cloned ( )
1995+ . map_err ( |_| plan_datafusion_err ! ( "Column '{}' not found" , name) )
19951996 } )
19961997 . collect ( )
19971998 }
0 commit comments