Skip to content

Commit

Permalink
fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
comphead committed Jun 8, 2024
1 parent 311e13e commit c77d523
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion core/src/execution/datafusion/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ impl PhysicalPlanner {

impl From<DataFusionError> for ExecutionError {
fn from(value: DataFusionError) -> Self {
ExecutionError::DataFusionError(value.to_string())
ExecutionError::DataFusionError(value.message().to_string())
}
}

Expand Down Expand Up @@ -1554,6 +1554,7 @@ mod tests {
spark_operator,
};

use crate::execution::operators::ExecutionError;
use spark_expression::expr::ExprStruct::*;
use spark_operator::{operator::OpStruct, Operator};

Expand Down Expand Up @@ -1743,6 +1744,14 @@ mod tests {
assert!(output.is_empty());
}

#[tokio::test()]
async fn from_datafusion_error_to_comet() {
let err_msg = "exec error";
let err = datafusion_common::DataFusionError::Execution(err_msg.to_string());
let comet_err: ExecutionError = err.into();
assert_eq!(comet_err.to_string(), "Error from DataFusion: exec error.");
}

// Creates a filter operator which takes an `Int32Array` and selects rows that are equal to
// `value`.
fn create_filter(child_op: spark_operator::Operator, value: i32) -> spark_operator::Operator {
Expand Down
8 changes: 4 additions & 4 deletions core/src/execution/operators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ pub use copy::*;
pub enum ExecutionError {
/// Simple error
#[allow(dead_code)]
#[error("General execution error with reason {0}.")]
#[error("General execution error with reason: {0}.")]
GeneralError(String),

/// Error when deserializing an operator.
#[error("Fail to deserialize to native operator with reason {0}.")]
#[error("Fail to deserialize to native operator with reason: {0}.")]
DeserializeError(String),

/// Error when processing Arrow array.
#[error("Fail to process Arrow array with reason {0}.")]
#[error("Fail to process Arrow array with reason: {0}.")]
ArrowError(String),

/// DataFusion error
#[error("Error from DataFusion {0}.")]
#[error("Error from DataFusion: {0}.")]
DataFusionError(String),
}

Expand Down

0 comments on commit c77d523

Please sign in to comment.