Skip to content

Apache DataFusion SQL Query Engine

ARROW-4895: [Rust] [DataFusion] Move error.rs to root of crate

Andy Grovec433267d4f06
diff --git a/rust/datafusion/src/datasource/csv.rs b/rust/datafusion/src/datasource/csv.rs
index a010526298..79b3cd2b7a 100644
--- a/rust/datafusion/src/datasource/csv.rs
+++ b/rust/datafusion/src/datasource/csv.rs
@@ -26,7 +26,7 @@ use arrow::datatypes::{Field, Schema};
use arrow::record_batch::RecordBatch;
use crate::datasource::{RecordBatchIterator, ScanResult, Table};
-use crate::execution::error::Result;
+use crate::error::Result;
/// Represents a CSV file with a provided schema
pub struct CsvFile {
diff --git a/rust/datafusion/src/datasource/datasource.rs b/rust/datafusion/src/datasource/datasource.rs
index 7e48f19b55..7db351eeb5 100644
--- a/rust/datafusion/src/datasource/datasource.rs
+++ b/rust/datafusion/src/datasource/datasource.rs
@@ -22,7 +22,7 @@ use std::sync::{Arc, Mutex};
use arrow::datatypes::Schema;
use arrow::record_batch::RecordBatch;
-use crate::execution::error::Result;
+use crate::error::Result;
pub type ScanResult = Arc<Mutex<RecordBatchIterator>>;
diff --git a/rust/datafusion/src/datasource/memory.rs b/rust/datafusion/src/datasource/memory.rs
index e5955e5125..e12bec566e 100644
--- a/rust/datafusion/src/datasource/memory.rs
+++ b/rust/datafusion/src/datasource/memory.rs
@@ -25,7 +25,7 @@ use arrow::datatypes::{Field, Schema};
use arrow::record_batch::RecordBatch;
use crate::datasource::{RecordBatchIterator, ScanResult, Table};
-use crate::execution::error::{ExecutionError, Result};
+use crate::error::{ExecutionError, Result};
/// In-memory table
pub struct MemTable {
diff --git a/rust/datafusion/src/datasource/parquet.rs b/rust/datafusion/src/datasource/parquet.rs
index 3fb4a3c07f..d01781075f 100644
--- a/rust/datafusion/src/datasource/parquet.rs
+++ b/rust/datafusion/src/datasource/parquet.rs
@@ -32,7 +32,7 @@ use parquet::file::reader::*;
use parquet::reader::schema::parquet_to_arrow_schema;
use crate::datasource::{RecordBatchIterator, ScanResult, Table};
-use crate::execution::error::{ExecutionError, Result};
+use crate::error::{ExecutionError, Result};
pub struct ParquetTable {
filename: String,
diff --git a/rust/datafusion/src/execution/error.rs b/rust/datafusion/src/error.rs
similarity index 86%
rename from rust/datafusion/src/execution/error.rs
rename to rust/datafusion/src/error.rs
index b734e6b4c6..26d48b125f 100644
--- a/rust/datafusion/src/execution/error.rs
+++ b/rust/datafusion/src/error.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-//! Error types
+//! DataFusion error types
use std::io::Error;
use std::result;
@@ -27,17 +27,26 @@ use sqlparser::sqlparser::ParserError;
pub type Result<T> = result::Result<T, ExecutionError>;
-/// DataFusion execution error
+/// DataFusion error
#[derive(Debug)]
pub enum ExecutionError {
+ /// Wraps an error from the Arrow crate
+ ArrowError(ArrowError),
+ /// Wraps an error from the Parquet crate
+ ParquetError(ParquetError),
+ /// I/O error
IoError(Error),
+ /// SQL parser error
ParserError(ParserError),
+ /// General error
General(String),
+ /// Invalid column error
InvalidColumn(String),
+ /// Missing functionality
NotImplemented(String),
+ /// Internal error
InternalError(String),
- ArrowError(ArrowError),
- ParquetError(ParquetError),
+ /// Query engine execution error
ExecutionError(String),
}
diff --git a/rust/datafusion/src/execution/aggregate.rs b/rust/datafusion/src/execution/aggregate.rs
index d982e39fb0..aec187f24b 100644
--- a/rust/datafusion/src/execution/aggregate.rs
+++ b/rust/datafusion/src/execution/aggregate.rs
@@ -29,7 +29,7 @@ use arrow::compute;
use arrow::datatypes::{DataType, Schema};
use arrow::record_batch::RecordBatch;
-use crate::execution::error::{ExecutionError, Result};
+use crate::error::{ExecutionError, Result};
use crate::execution::expression::{AggregateType, RuntimeExpr};
use crate::execution::relation::Relation;
use crate::logicalplan::ScalarValue;
diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs
index 5f40786ecf..4413ff95dc 100644
--- a/rust/datafusion/src/execution/context.rs
+++ b/rust/datafusion/src/execution/context.rs
@@ -27,8 +27,8 @@ use arrow::datatypes::*;
use crate::datasource::csv::CsvFile;
use crate::datasource::datasource::Table;
+use crate::error::{ExecutionError, Result};
use crate::execution::aggregate::AggregateRelation;
-use crate::execution::error::{ExecutionError, Result};
use crate::execution::expression::*;
use crate::execution::filter::FilterRelation;
use crate::execution::limit::LimitRelation;
diff --git a/rust/datafusion/src/execution/expression.rs b/rust/datafusion/src/execution/expression.rs
index 5b01af5dbd..6f10d88f83 100644
--- a/rust/datafusion/src/execution/expression.rs
+++ b/rust/datafusion/src/execution/expression.rs
@@ -25,9 +25,9 @@ use arrow::compute;
use arrow::datatypes::{DataType, Schema};
use arrow::record_batch::RecordBatch;
-use super::super::logicalplan::{Expr, Operator, ScalarValue};
-use super::context::ExecutionContext;
-use super::error::{ExecutionError, Result};
+use crate::error::{ExecutionError, Result};
+use crate::execution::context::ExecutionContext;
+use crate::logicalplan::{Expr, Operator, ScalarValue};
/// Compiled Expression (basically just a closure to evaluate the expression at runtime)
pub type CompiledExpr = Rc<Fn(&RecordBatch) -> Result<ArrayRef>>;
diff --git a/rust/datafusion/src/execution/filter.rs b/rust/datafusion/src/execution/filter.rs
index 5100f2640c..395a8946c9 100644
--- a/rust/datafusion/src/execution/filter.rs
+++ b/rust/datafusion/src/execution/filter.rs
@@ -26,9 +26,9 @@ use arrow::compute::array_ops::filter;
use arrow::datatypes::Schema;
use arrow::record_batch::RecordBatch;
-use super::error::{ExecutionError, Result};
-use super::expression::RuntimeExpr;
-use super::relation::Relation;
+use crate::error::{ExecutionError, Result};
+use crate::execution::expression::RuntimeExpr;
+use crate::execution::relation::Relation;
/// Implementation of a filter relation
pub(super) struct FilterRelation {
diff --git a/rust/datafusion/src/execution/limit.rs b/rust/datafusion/src/execution/limit.rs
index 80d70fe1a6..b861139db1 100644
--- a/rust/datafusion/src/execution/limit.rs
+++ b/rust/datafusion/src/execution/limit.rs
@@ -26,8 +26,8 @@ use arrow::compute::array_ops::limit;
use arrow::datatypes::Schema;
use arrow::record_batch::RecordBatch;
-use super::error::{ExecutionError, Result};
-use super::relation::Relation;
+use crate::error::{ExecutionError, Result};
+use crate::execution::relation::Relation;
/// Implementation of a LIMIT relation
pub(super) struct LimitRelation {
diff --git a/rust/datafusion/src/execution/mod.rs b/rust/datafusion/src/execution/mod.rs
index 0ece1e99eb..475c5b71c7 100644
--- a/rust/datafusion/src/execution/mod.rs
+++ b/rust/datafusion/src/execution/mod.rs
@@ -19,7 +19,6 @@
pub mod aggregate;
pub mod context;
-pub mod error;
pub mod expression;
pub mod filter;
pub mod limit;
diff --git a/rust/datafusion/src/execution/projection.rs b/rust/datafusion/src/execution/projection.rs
index 5c95c6532d..2309897a9d 100644
--- a/rust/datafusion/src/execution/projection.rs
+++ b/rust/datafusion/src/execution/projection.rs
@@ -28,7 +28,7 @@ use arrow::array::ArrayRef;
use arrow::datatypes::{Field, Schema};
use arrow::record_batch::RecordBatch;
-use crate::execution::error::Result;
+use crate::error::Result;
use crate::execution::expression::RuntimeExpr;
use crate::execution::relation::Relation;
diff --git a/rust/datafusion/src/execution/relation.rs b/rust/datafusion/src/execution/relation.rs
index ec6276c688..98a0b4adde 100644
--- a/rust/datafusion/src/execution/relation.rs
+++ b/rust/datafusion/src/execution/relation.rs
@@ -25,7 +25,7 @@ use arrow::datatypes::Schema;
use arrow::record_batch::RecordBatch;
use crate::datasource::RecordBatchIterator;
-use crate::execution::error::Result;
+use crate::error::Result;
/// trait for all relations (a relation is essentially just an iterator over batches
/// of data, with a known schema)
diff --git a/rust/datafusion/src/lib.rs b/rust/datafusion/src/lib.rs
index 63f4ab77b2..0cce2289c6 100644
--- a/rust/datafusion/src/lib.rs
+++ b/rust/datafusion/src/lib.rs
@@ -25,6 +25,7 @@ extern crate serde_json;
extern crate sqlparser;
pub mod datasource;
+pub mod error;
pub mod execution;
pub mod logicalplan;
pub mod optimizer;
diff --git a/rust/datafusion/src/sql/planner.rs b/rust/datafusion/src/sql/planner.rs
index 934ba2b5ac..45e2f8ef11 100644
--- a/rust/datafusion/src/sql/planner.rs
+++ b/rust/datafusion/src/sql/planner.rs
@@ -20,7 +20,7 @@
use std::string::String;
use std::sync::Arc;
-use crate::execution::error::*;
+use crate::error::*;
use crate::logicalplan::*;
use arrow::datatypes::*;