diff --git a/src/catalog/src/error.rs b/src/catalog/src/error.rs index 7f345adf97b9..eaad22f4c9f6 100644 --- a/src/catalog/src/error.rs +++ b/src/catalog/src/error.rs @@ -19,10 +19,7 @@ use common_error::ext::{BoxedError, ErrorExt}; use common_error::status_code::StatusCode; use common_macro::stack_trace_debug; use datafusion::error::DataFusionError; -use datatypes::prelude::ConcreteDataType; use snafu::{Location, Snafu}; -use table::metadata::TableId; -use tokio::task::JoinError; #[derive(Snafu)] #[snafu(visibility(pub))] @@ -65,19 +62,6 @@ pub enum Error { location: Location, source: BoxedError, }, - #[snafu(display("Failed to open system catalog table"))] - OpenSystemCatalog { - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - - #[snafu(display("Failed to create system catalog table"))] - CreateSystemCatalog { - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, #[snafu(display("Failed to create table, table info: {}", table_info))] CreateTable { @@ -94,52 +78,6 @@ pub enum Error { location: Location, }, - #[snafu(display( - "System catalog table type mismatch, expected: binary, found: {:?}", - data_type, - ))] - SystemCatalogTypeMismatch { - data_type: ConcreteDataType, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Invalid system catalog entry type: {:?}", entry_type))] - InvalidEntryType { - entry_type: Option, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Invalid system catalog key: {:?}", key))] - InvalidKey { - key: Option, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Catalog value is not present"))] - EmptyValue { - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to deserialize value"))] - ValueDeserialize { - #[snafu(source)] - error: serde_json::error::Error, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Table engine not found: {}", engine_name))] - TableEngineNotFound { - engine_name: String, - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - #[snafu(display("Cannot find catalog by name: {}", catalog_name))] CatalogNotFound { catalog_name: String, @@ -169,48 +107,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Schema {} already exists", schema))] - SchemaExists { - schema: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Operation {} not implemented yet", operation))] - Unimplemented { - operation: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Operation {} not supported", op))] - NotSupported { - op: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to open table {table_id}"))] - OpenTable { - table_id: TableId, - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - - #[snafu(display("Failed to open table in parallel"))] - ParallelOpenTable { - #[snafu(source)] - error: JoinError, - }, - - #[snafu(display("Table not found while opening table, table info: {}", table_info))] - TableNotFound { - table_info: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("View info not found: {}", name))] ViewInfoNotFound { name: String, @@ -224,13 +120,6 @@ pub enum Error { #[snafu(display("Failed to find region routes"))] FindRegionRoutes { source: partition::error::Error }, - #[snafu(display("Failed to read system catalog table records"))] - ReadSystemCatalog { - #[snafu(implicit)] - location: Location, - source: common_recordbatch::error::Error, - }, - #[snafu(display("Failed to create recordbatch"))] CreateRecordBatch { #[snafu(implicit)] @@ -238,20 +127,6 @@ pub enum Error { source: common_recordbatch::error::Error, }, - #[snafu(display("Failed to insert table creation record to system catalog"))] - InsertCatalogRecord { - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - - #[snafu(display("Failed to scan system catalog table"))] - SystemCatalogTableScan { - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - #[snafu(display("Internal error"))] Internal { #[snafu(implicit)] @@ -265,13 +140,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to execute system catalog table scan"))] - SystemCatalogTableScanExec { - #[snafu(implicit)] - location: Location, - source: common_query::error::Error, - }, - #[snafu(display("Failed to decode logical plan for view: {}", name))] DecodePlan { name: String, @@ -280,13 +148,6 @@ pub enum Error { source: common_query::error::Error, }, - #[snafu(display("Cannot parse catalog value"))] - InvalidCatalogValue { - #[snafu(implicit)] - location: Location, - source: common_catalog::error::Error, - }, - #[snafu(display("Failed to perform metasrv operation"))] Metasrv { #[snafu(implicit)] @@ -312,20 +173,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Table schema mismatch"))] - TableSchemaMismatch { - #[snafu(implicit)] - location: Location, - source: table::error::Error, - }, - - #[snafu(display("A generic error has occurred, msg: {}", msg))] - Generic { - msg: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Table metadata manager error"))] TableMetadataManager { source: common_meta::error::Error, @@ -366,63 +213,37 @@ pub type Result = std::result::Result; impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { - Error::InvalidKey { .. } - | Error::SchemaNotFound { .. } + Error::SchemaNotFound { .. } | Error::CatalogNotFound { .. } | Error::FindPartitions { .. } | Error::FindRegionRoutes { .. } - | Error::InvalidEntryType { .. } | Error::CacheNotFound { .. } - | Error::CastManager { .. } - | Error::ParallelOpenTable { .. } => StatusCode::Unexpected, + | Error::CastManager { .. } => StatusCode::Unexpected, - Error::ViewInfoNotFound { .. } | Error::TableNotFound { .. } => { - StatusCode::TableNotFound - } + Error::ViewInfoNotFound { .. } => StatusCode::TableNotFound, - Error::SystemCatalog { .. } - | Error::EmptyValue { .. } - | Error::ValueDeserialize { .. } => StatusCode::StorageUnavailable, + Error::SystemCatalog { .. } => StatusCode::StorageUnavailable, - Error::Generic { .. } - | Error::SystemCatalogTypeMismatch { .. } - | Error::UpgradeWeakCatalogManagerRef { .. } => StatusCode::Internal, - - Error::ReadSystemCatalog { source, .. } | Error::CreateRecordBatch { source, .. } => { - source.status_code() - } - Error::InvalidCatalogValue { source, .. } => source.status_code(), + Error::UpgradeWeakCatalogManagerRef { .. } => StatusCode::Internal, + Error::CreateRecordBatch { source, .. } => source.status_code(), Error::TableExists { .. } => StatusCode::TableAlreadyExists, Error::TableNotExist { .. } => StatusCode::TableNotFound, - Error::SchemaExists { .. } | Error::TableEngineNotFound { .. } => { - StatusCode::InvalidArguments - } - Error::ListCatalogs { source, .. } | Error::ListNodes { source, .. } | Error::ListSchemas { source, .. } | Error::ListTables { source, .. } => source.status_code(), - Error::OpenSystemCatalog { source, .. } - | Error::CreateSystemCatalog { source, .. } - | Error::InsertCatalogRecord { source, .. } - | Error::OpenTable { source, .. } - | Error::CreateTable { source, .. } - | Error::TableSchemaMismatch { source, .. } => source.status_code(), + Error::CreateTable { source, .. } => source.status_code(), Error::Metasrv { source, .. } => source.status_code(), - Error::SystemCatalogTableScan { source, .. } => source.status_code(), - Error::DecodePlan { source, .. } | Error::SystemCatalogTableScanExec { source, .. } => { - source.status_code() - } + Error::DecodePlan { source, .. } => source.status_code(), Error::InvalidTableInfoInCatalog { source, .. } => source.status_code(), Error::CompileScriptInternal { source, .. } | Error::Internal { source, .. } => { source.status_code() } - Error::Unimplemented { .. } | Error::NotSupported { .. } => StatusCode::Unsupported, Error::QueryAccessDenied { .. } => StatusCode::AccessDenied, Error::Datafusion { .. } => StatusCode::EngineExecuteQuery, Error::TableMetadataManager { source, .. } => source.status_code(), @@ -460,11 +281,6 @@ mod tests { .status_code() ); - assert_eq!( - StatusCode::Unexpected, - InvalidKeySnafu { key: None }.build().status_code() - ); - assert_eq!( StatusCode::StorageUnavailable, Error::SystemCatalog { @@ -473,19 +289,6 @@ mod tests { } .status_code() ); - - assert_eq!( - StatusCode::Internal, - Error::SystemCatalogTypeMismatch { - data_type: ConcreteDataType::binary_datatype(), - location: Location::generate(), - } - .status_code() - ); - assert_eq!( - StatusCode::StorageUnavailable, - EmptyValueSnafu {}.build().status_code() - ); } #[test] diff --git a/src/operator/src/error.rs b/src/operator/src/error.rs index 54e85102f88f..0a6d10143f9b 100644 --- a/src/operator/src/error.rs +++ b/src/operator/src/error.rs @@ -22,7 +22,6 @@ use datafusion::parquet; use datatypes::arrow::error::ArrowError; use servers::define_into_tonic_status; use snafu::{Location, Snafu}; -use sql::ast::Value; #[derive(Snafu)] #[snafu(visibility(pub))] @@ -120,14 +119,6 @@ pub enum Error { source: query::error::Error, }, - #[snafu(display("Failed to convert value to sql value: {}", value))] - ConvertSqlValue { - value: Value, - #[snafu(implicit)] - location: Location, - source: sql::error::Error, - }, - #[snafu(display("Column datatype error"))] ColumnDataType { #[snafu(implicit)] @@ -542,13 +533,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to prepare immutable table"))] - PrepareImmutableTable { - #[snafu(implicit)] - location: Location, - source: query::error::Error, - }, - #[snafu(display("Invalid COPY parameter, key: {}, value: {}", key, value))] InvalidCopyParameter { key: String, @@ -571,20 +555,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to read record batch"))] - ReadRecordBatch { - source: common_recordbatch::error::Error, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to build column vectors"))] - BuildColumnVectors { - source: common_recordbatch::error::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Missing insert body"))] MissingInsertBody { source: sql::error::Error, @@ -737,7 +707,6 @@ impl ErrorExt for Error { | Error::ColumnNotFound { .. } | Error::BuildRegex { .. } | Error::InvalidSchema { .. } - | Error::PrepareImmutableTable { .. } | Error::BuildCsvConfig { .. } | Error::ProjectSchema { .. } | Error::UnsupportedFormat { .. } @@ -761,9 +730,7 @@ impl ErrorExt for Error { Error::TableMetadataManager { source, .. } => source.status_code(), - Error::ConvertSqlValue { source, .. } | Error::ParseSql { source, .. } => { - source.status_code() - } + Error::ParseSql { source, .. } => source.status_code(), Error::InvalidateTableCache { source, .. } => source.status_code(), @@ -843,10 +810,6 @@ impl ErrorExt for Error { StatusCode::InvalidArguments } - Error::ReadRecordBatch { source, .. } | Error::BuildColumnVectors { source, .. } => { - source.status_code() - } - Error::ColumnDefaultValue { source, .. } => source.status_code(), Error::DdlWithMultiCatalogs { .. } diff --git a/src/query/src/error.rs b/src/query/src/error.rs index 7c0160d96042..35d3fbdb17b9 100644 --- a/src/query/src/error.rs +++ b/src/query/src/error.rs @@ -56,20 +56,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Catalog not found: {}", catalog))] - CatalogNotFound { - catalog: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Schema not found: {}", schema))] - SchemaNotFound { - schema: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Table not found: {}", table))] TableNotFound { table: String, @@ -137,13 +123,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid timestamp `{}`", raw))] - InvalidTimestamp { - raw: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to parse float number `{}`", raw))] ParseFloat { raw: String, @@ -347,13 +326,10 @@ impl ErrorExt for Error { } UnsupportedExpr { .. } | Unimplemented { .. } - | CatalogNotFound { .. } - | SchemaNotFound { .. } | TableNotFound { .. } | UnknownTable { .. } | TimeIndexNotFound { .. } | ParseTimestamp { .. } - | InvalidTimestamp { .. } | ParseFloat { .. } | MissingRequiredField { .. } | BuildRegex { .. }