Skip to content

Commit 40e4c60

Browse files
alambJefffrey
andauthored
Minor: Improve DataFusionError documentation (#8792)
* Minor: Improve `DataFusionError` documentation * Apply suggestions from code review Co-authored-by: Jeffrey Vo <[email protected]> --------- Co-authored-by: Jeffrey Vo <[email protected]>
1 parent 85719df commit 40e4c60

File tree

1 file changed

+50
-24
lines changed

1 file changed

+50
-24
lines changed

datafusion/common/src/error.rs

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,56 +47,82 @@ pub type GenericError = Box<dyn Error + Send + Sync>;
4747
#[derive(Debug)]
4848
pub enum DataFusionError {
4949
/// Error returned by arrow.
50+
///
5051
/// 2nd argument is for optional backtrace
5152
ArrowError(ArrowError, Option<String>),
52-
/// Wraps an error from the Parquet crate
53+
/// Error when reading / writing Parquet data.
5354
#[cfg(feature = "parquet")]
5455
ParquetError(ParquetError),
55-
/// Wraps an error from the Avro crate
56+
/// Error when reading Avro data.
5657
#[cfg(feature = "avro")]
5758
AvroError(AvroError),
58-
/// Wraps an error from the object_store crate
59+
/// Error when reading / writing to / from an object_store (e.g. S3 or LocalFile)
5960
#[cfg(feature = "object_store")]
6061
ObjectStore(object_store::Error),
61-
/// Error associated to I/O operations and associated traits.
62+
/// Error when an I/O operation fails
6263
IoError(io::Error),
63-
/// Error returned when SQL is syntactically incorrect.
64+
/// Error when SQL is syntactically incorrect.
65+
///
6466
/// 2nd argument is for optional backtrace
6567
SQL(ParserError, Option<String>),
66-
/// Error returned on a branch that we know it is possible
67-
/// but to which we still have no implementation for.
68-
/// Often, these errors are tracked in our issue tracker.
68+
/// Error when a feature is not yet implemented.
69+
///
70+
/// These errors are sometimes returned for features that are still in
71+
/// development and are not entirely complete. Often, these errors are
72+
/// tracked in our issue tracker.
6973
NotImplemented(String),
70-
/// Error returned as a consequence of an error in DataFusion.
71-
/// This error should not happen in normal usage of DataFusion.
74+
/// Error due to bugs in DataFusion
7275
///
73-
/// DataFusions has internal invariants that the compiler is not
74-
/// always able to check. This error is raised when one of those
75-
/// invariants is not verified during execution.
76+
/// This error should not happen in normal usage of DataFusion. It results
77+
/// from something that wasn't expected/anticipated by the implementation
78+
/// and that is most likely a bug (the error message even encourages users
79+
/// to open a bug report). A user should not be able to trigger internal
80+
/// errors under normal circumstances by feeding in malformed queries, bad
81+
/// data, etc.
82+
///
83+
/// Note that I/O errors (or any error that happens due to external systems)
84+
/// do NOT fall under this category. See other variants such as
85+
/// [`Self::IoError`] and [`Self::External`].
86+
///
87+
/// DataFusions has internal invariants that the compiler is not always able
88+
/// to check. This error is raised when one of those invariants does not
89+
/// hold for some reason.
7690
Internal(String),
77-
/// This error happens whenever a plan is not valid. Examples include
78-
/// impossible casts.
91+
/// Error during planning of the query.
92+
///
93+
/// This error happens when the user provides a bad query or plan, for
94+
/// example the user attempts to call a function that doesn't exist, or if
95+
/// the types of a function call are not supported.
7996
Plan(String),
80-
/// This error happens when an invalid or unsupported option is passed
81-
/// in a SQL statement
97+
/// Error for invalid or unsupported configuration options.
8298
Configuration(String),
83-
/// This error happens with schema-related errors, such as schema inference not possible
84-
/// and non-unique column names.
99+
/// Error when there is a problem with the query related to schema.
100+
///
101+
/// This error can be returned in cases such as when schema inference is not
102+
/// possible and when column names are not unique.
103+
///
85104
/// 2nd argument is for optional backtrace
86105
/// Boxing the optional backtrace to prevent <https://rust-lang.github.io/rust-clippy/master/index.html#/result_large_err>
87106
SchemaError(SchemaError, Box<Option<String>>),
88-
/// Error returned during execution of the query.
89-
/// Examples include files not found, errors in parsing certain types.
107+
/// Error during execution of the query.
108+
///
109+
/// This error is returned when an error happens during execution due to a
110+
/// malformed input. For example, the user passed malformed arguments to a
111+
/// SQL method, opened a CSV file that is broken, or tried to divide an
112+
/// integer by zero.
90113
Execution(String),
91-
/// This error is thrown when a consumer cannot acquire memory from the Memory Manager
92-
/// we can just cancel the execution of the partition.
114+
/// Error when resources (such as memory of scratch disk space) are exhausted.
115+
///
116+
/// This error is thrown when a consumer cannot acquire additional memory
117+
/// or other resources needed to execute the query from the Memory Manager.
93118
ResourcesExhausted(String),
94119
/// Errors originating from outside DataFusion's core codebase.
120+
///
95121
/// For example, a custom S3Error from the crate datafusion-objectstore-s3
96122
External(GenericError),
97123
/// Error with additional context
98124
Context(String, Box<DataFusionError>),
99-
/// Errors originating from either mapping LogicalPlans to/from Substrait plans
125+
/// Errors from either mapping LogicalPlans to/from Substrait plans
100126
/// or serializing/deserializing protobytes to Substrait plans
101127
Substrait(String),
102128
}

0 commit comments

Comments
 (0)