This is an automated email from the ASF dual-hosted git repository.

xudong963 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/master by this push:
     new 8944581ce Use thiserror in sqllogictest erorr (#4657)
8944581ce is described below

commit 8944581ce3d0f7d24e1d3ef62ff04fcde63d8c2a
Author: xudong.w <[email protected]>
AuthorDate: Fri Dec 16 22:24:39 2022 +0800

    Use thiserror in sqllogictest erorr (#4657)
---
 datafusion/core/Cargo.toml                       |  1 +
 datafusion/core/tests/sqllogictests/src/error.rs | 28 +++++-------------------
 2 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/datafusion/core/Cargo.toml b/datafusion/core/Cargo.toml
index e8c615e78..898237a83 100644
--- a/datafusion/core/Cargo.toml
+++ b/datafusion/core/Cargo.toml
@@ -112,6 +112,7 @@ rstest = "0.16.0"
 sqllogictest = "0.9.0"
 sqlparser = "0.28"
 test-utils = { path = "../../test-utils" }
+thiserror = "1.0.37"
 
 [[bench]]
 harness = false
diff --git a/datafusion/core/tests/sqllogictests/src/error.rs 
b/datafusion/core/tests/sqllogictests/src/error.rs
index 0b073870d..d645e054b 100644
--- a/datafusion/core/tests/sqllogictests/src/error.rs
+++ b/datafusion/core/tests/sqllogictests/src/error.rs
@@ -19,21 +19,24 @@ use arrow::error::ArrowError;
 use datafusion_common::DataFusionError;
 use sqllogictest::TestError;
 use sqlparser::parser::ParserError;
-use std::error;
-use std::fmt::{Display, Formatter};
+use thiserror::Error;
 
 pub type Result<T> = std::result::Result<T, DFSqlLogicTestError>;
 
 /// DataFusion sql-logicaltest error
-#[derive(Debug)]
+#[derive(Debug, Error)]
 pub enum DFSqlLogicTestError {
     /// Error from sqllogictest-rs
+    #[error("SqlLogicTest error(from sqllogictest-rs crate): {0}")]
     SqlLogicTest(TestError),
     /// Error from datafusion
+    #[error("DataFusion error: {0}")]
     DataFusion(DataFusionError),
     /// Error returned when SQL is syntactically incorrect.
+    #[error("SQL Parser error: {0}")]
     Sql(ParserError),
     /// Error from arrow-rs
+    #[error("Arrow error: {0}")]
     Arrow(ArrowError),
 }
 
@@ -60,22 +63,3 @@ impl From<ArrowError> for DFSqlLogicTestError {
         DFSqlLogicTestError::Arrow(value)
     }
 }
-
-impl Display for DFSqlLogicTestError {
-    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
-        match self {
-            DFSqlLogicTestError::SqlLogicTest(error) => write!(
-                f,
-                "SqlLogicTest error(from sqllogictest-rs crate): {}",
-                error
-            ),
-            DFSqlLogicTestError::DataFusion(error) => {
-                write!(f, "DataFusion error: {}", error)
-            }
-            DFSqlLogicTestError::Sql(error) => write!(f, "SQL Parser error: 
{}", error),
-            DFSqlLogicTestError::Arrow(error) => write!(f, "Arrow error: {}", 
error),
-        }
-    }
-}
-
-impl error::Error for DFSqlLogicTestError {}

Reply via email to