@@ -53,22 +53,22 @@ pub enum DataFusionError {
5353 /// Error returned by arrow.
5454 ///
5555 /// 2nd argument is for optional backtrace
56- ArrowError ( ArrowError , Option < String > ) ,
56+ ArrowError ( Box < ArrowError > , Option < String > ) ,
5757 /// Error when reading / writing Parquet data.
5858 #[ cfg( feature = "parquet" ) ]
59- ParquetError ( ParquetError ) ,
59+ ParquetError ( Box < ParquetError > ) ,
6060 /// Error when reading Avro data.
6161 #[ cfg( feature = "avro" ) ]
6262 AvroError ( Box < AvroError > ) ,
6363 /// Error when reading / writing to / from an object_store (e.g. S3 or LocalFile)
6464 #[ cfg( feature = "object_store" ) ]
65- ObjectStore ( object_store:: Error ) ,
65+ ObjectStore ( Box < object_store:: Error > ) ,
6666 /// Error when an I/O operation fails
6767 IoError ( io:: Error ) ,
6868 /// Error when SQL is syntactically incorrect.
6969 ///
7070 /// 2nd argument is for optional backtrace
71- SQL ( ParserError , Option < String > ) ,
71+ SQL ( Box < ParserError > , Option < String > ) ,
7272 /// Error when a feature is not yet implemented.
7373 ///
7474 /// These errors are sometimes returned for features that are still in
@@ -107,7 +107,7 @@ pub enum DataFusionError {
107107 ///
108108 /// 2nd argument is for optional backtrace
109109 /// Boxing the optional backtrace to prevent <https://rust-lang.github.io/rust-clippy/master/index.html#/result_large_err>
110- SchemaError ( SchemaError , Box < Option < String > > ) ,
110+ SchemaError ( Box < SchemaError > , Box < Option < String > > ) ,
111111 /// Error during execution of the query.
112112 ///
113113 /// This error is returned when an error happens during execution due to a
@@ -118,7 +118,7 @@ pub enum DataFusionError {
118118 /// [`JoinError`] during execution of the query.
119119 ///
120120 /// This error can't occur for unjoined tasks, such as execution shutdown.
121- ExecutionJoin ( JoinError ) ,
121+ ExecutionJoin ( Box < JoinError > ) ,
122122 /// Error when resources (such as memory of scratch disk space) are exhausted.
123123 ///
124124 /// This error is thrown when a consumer cannot acquire additional memory
@@ -276,14 +276,14 @@ impl From<io::Error> for DataFusionError {
276276
277277impl From < ArrowError > for DataFusionError {
278278 fn from ( e : ArrowError ) -> Self {
279- DataFusionError :: ArrowError ( e , None )
279+ DataFusionError :: ArrowError ( Box :: new ( e ) , None )
280280 }
281281}
282282
283283impl From < DataFusionError > for ArrowError {
284284 fn from ( e : DataFusionError ) -> Self {
285285 match e {
286- DataFusionError :: ArrowError ( e, _) => e,
286+ DataFusionError :: ArrowError ( e, _) => * e,
287287 DataFusionError :: External ( e) => ArrowError :: ExternalError ( e) ,
288288 other => ArrowError :: ExternalError ( Box :: new ( other) ) ,
289289 }
@@ -304,7 +304,7 @@ impl From<&Arc<DataFusionError>> for DataFusionError {
304304#[ cfg( feature = "parquet" ) ]
305305impl From < ParquetError > for DataFusionError {
306306 fn from ( e : ParquetError ) -> Self {
307- DataFusionError :: ParquetError ( e )
307+ DataFusionError :: ParquetError ( Box :: new ( e ) )
308308 }
309309}
310310
@@ -318,20 +318,20 @@ impl From<AvroError> for DataFusionError {
318318#[ cfg( feature = "object_store" ) ]
319319impl From < object_store:: Error > for DataFusionError {
320320 fn from ( e : object_store:: Error ) -> Self {
321- DataFusionError :: ObjectStore ( e )
321+ DataFusionError :: ObjectStore ( Box :: new ( e ) )
322322 }
323323}
324324
325325#[ cfg( feature = "object_store" ) ]
326326impl From < object_store:: path:: Error > for DataFusionError {
327327 fn from ( e : object_store:: path:: Error ) -> Self {
328- DataFusionError :: ObjectStore ( e. into ( ) )
328+ DataFusionError :: ObjectStore ( Box :: new ( e. into ( ) ) )
329329 }
330330}
331331
332332impl From < ParserError > for DataFusionError {
333333 fn from ( e : ParserError ) -> Self {
334- DataFusionError :: SQL ( e , None )
334+ DataFusionError :: SQL ( Box :: new ( e ) , None )
335335 }
336336}
337337
@@ -361,22 +361,22 @@ impl Display for DataFusionError {
361361impl Error for DataFusionError {
362362 fn source ( & self ) -> Option < & ( dyn Error + ' static ) > {
363363 match self {
364- DataFusionError :: ArrowError ( e, _) => Some ( e) ,
364+ DataFusionError :: ArrowError ( e, _) => Some ( e. as_ref ( ) ) ,
365365 #[ cfg( feature = "parquet" ) ]
366- DataFusionError :: ParquetError ( e) => Some ( e) ,
366+ DataFusionError :: ParquetError ( e) => Some ( e. as_ref ( ) ) ,
367367 #[ cfg( feature = "avro" ) ]
368- DataFusionError :: AvroError ( e) => Some ( e) ,
368+ DataFusionError :: AvroError ( e) => Some ( e. as_ref ( ) ) ,
369369 #[ cfg( feature = "object_store" ) ]
370- DataFusionError :: ObjectStore ( e) => Some ( e) ,
370+ DataFusionError :: ObjectStore ( e) => Some ( e. as_ref ( ) ) ,
371371 DataFusionError :: IoError ( e) => Some ( e) ,
372- DataFusionError :: SQL ( e, _) => Some ( e) ,
372+ DataFusionError :: SQL ( e, _) => Some ( e. as_ref ( ) ) ,
373373 DataFusionError :: NotImplemented ( _) => None ,
374374 DataFusionError :: Internal ( _) => None ,
375375 DataFusionError :: Configuration ( _) => None ,
376376 DataFusionError :: Plan ( _) => None ,
377- DataFusionError :: SchemaError ( e, _) => Some ( e) ,
377+ DataFusionError :: SchemaError ( e, _) => Some ( e. as_ref ( ) ) ,
378378 DataFusionError :: Execution ( _) => None ,
379- DataFusionError :: ExecutionJoin ( e) => Some ( e) ,
379+ DataFusionError :: ExecutionJoin ( e) => Some ( e. as_ref ( ) ) ,
380380 DataFusionError :: ResourcesExhausted ( _) => None ,
381381 DataFusionError :: External ( e) => Some ( e. as_ref ( ) ) ,
382382 DataFusionError :: Context ( _, e) => Some ( e. as_ref ( ) ) ,
@@ -828,7 +828,7 @@ make_error!(resources_err, resources_datafusion_err, ResourcesExhausted);
828828#[ macro_export]
829829macro_rules! sql_datafusion_err {
830830 ( $ERR: expr $( ; diagnostic = $DIAG: expr) ?) => { {
831- let err = DataFusionError :: SQL ( $ERR, Some ( DataFusionError :: get_back_trace( ) ) ) ;
831+ let err = DataFusionError :: SQL ( Box :: new ( $ERR) , Some ( DataFusionError :: get_back_trace( ) ) ) ;
832832 $(
833833 let err = err. with_diagnostic( $DIAG) ;
834834 ) ?
@@ -852,7 +852,7 @@ macro_rules! sql_err {
852852#[ macro_export]
853853macro_rules! arrow_datafusion_err {
854854 ( $ERR: expr $( ; diagnostic = $DIAG: expr) ?) => { {
855- let err = DataFusionError :: ArrowError ( $ERR, Some ( DataFusionError :: get_back_trace( ) ) ) ;
855+ let err = DataFusionError :: ArrowError ( Box :: new ( $ERR) , Some ( DataFusionError :: get_back_trace( ) ) ) ;
856856 $(
857857 let err = err. with_diagnostic( $DIAG) ;
858858 ) ?
@@ -878,7 +878,7 @@ macro_rules! arrow_err {
878878macro_rules! schema_datafusion_err {
879879 ( $ERR: expr $( ; diagnostic = $DIAG: expr) ?) => { {
880880 let err = $crate:: error:: DataFusionError :: SchemaError (
881- $ERR,
881+ Box :: new ( $ERR) ,
882882 Box :: new( Some ( $crate:: error:: DataFusionError :: get_back_trace( ) ) ) ,
883883 ) ;
884884 $(
@@ -893,7 +893,7 @@ macro_rules! schema_datafusion_err {
893893macro_rules! schema_err {
894894 ( $ERR: expr $( ; diagnostic = $DIAG: expr) ?) => { {
895895 let err = $crate:: error:: DataFusionError :: SchemaError (
896- $ERR,
896+ Box :: new ( $ERR) ,
897897 Box :: new( Some ( $crate:: error:: DataFusionError :: get_back_trace( ) ) ) ,
898898 ) ;
899899 $(
@@ -951,11 +951,17 @@ pub fn add_possible_columns_to_diag(
951951
952952#[ cfg( test) ]
953953mod test {
954+ use std:: mem:: size_of;
954955 use std:: sync:: Arc ;
955956
956957 use crate :: error:: { DataFusionError , GenericError } ;
957958 use arrow:: error:: ArrowError ;
958959
960+ #[ test]
961+ fn test_datafusion_error_size ( ) {
962+ assert_eq ! ( size_of:: <DataFusionError >( ) , 40 ) ;
963+ }
964+
959965 #[ test]
960966 fn datafusion_error_to_arrow ( ) {
961967 let res = return_arrow_error ( ) . unwrap_err ( ) ;
@@ -1020,8 +1026,8 @@ mod test {
10201026
10211027 do_root_test (
10221028 DataFusionError :: ArrowError (
1023- ArrowError :: ExternalError ( Box :: new ( DataFusionError :: ResourcesExhausted (
1024- "foo" . to_string ( ) ,
1029+ Box :: new ( ArrowError :: ExternalError ( Box :: new (
1030+ DataFusionError :: ResourcesExhausted ( "foo" . to_string ( ) ) ,
10251031 ) ) ) ,
10261032 None ,
10271033 ) ,
@@ -1044,9 +1050,11 @@ mod test {
10441050
10451051 do_root_test (
10461052 DataFusionError :: ArrowError (
1047- ArrowError :: ExternalError ( Box :: new ( ArrowError :: ExternalError ( Box :: new (
1048- DataFusionError :: ResourcesExhausted ( "foo" . to_string ( ) ) ,
1049- ) ) ) ) ,
1053+ Box :: new ( ArrowError :: ExternalError ( Box :: new (
1054+ ArrowError :: ExternalError ( Box :: new (
1055+ DataFusionError :: ResourcesExhausted ( "foo" . to_string ( ) ) ,
1056+ ) ) ,
1057+ ) ) ) ,
10501058 None ,
10511059 ) ,
10521060 DataFusionError :: ResourcesExhausted ( "foo" . to_string ( ) ) ,
0 commit comments