From c699fc108a5687e01952ac3920edab68a306915e Mon Sep 17 00:00:00 2001 From: Yaroslav Litvinov Date: Mon, 10 Nov 2025 18:38:07 +0100 Subject: [PATCH 1/2] remove unused error variants --- crates/api-snowflake-rest/src/server/error.rs | 63 +------------------ crates/catalog-metastore/src/error.rs | 45 ------------- 2 files changed, 1 insertion(+), 107 deletions(-) diff --git a/crates/api-snowflake-rest/src/server/error.rs b/crates/api-snowflake-rest/src/server/error.rs index 1413a693..ea823a83 100644 --- a/crates/api-snowflake-rest/src/server/error.rs +++ b/crates/api-snowflake-rest/src/server/error.rs @@ -20,30 +20,6 @@ pub type Result = std::result::Result; #[snafu(visibility(pub(crate)))] #[error_stack_trace::debug] pub enum Error { - #[snafu(display("Failed to decompress GZip body"))] - GZipDecompress { - #[snafu(source)] - error: std::io::Error, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to parse login request"))] - LoginRequestParse { - #[snafu(source)] - error: serde_json::Error, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Failed to parse query body"))] - QueryBodyParse { - #[snafu(source)] - error: serde_json::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Missing auth token"))] MissingAuthToken { #[snafu(implicit)] @@ -56,20 +32,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Invalid uuid format"))] - InvalidUuidFormat { - #[snafu(source)] - error: uuid::Error, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Missing DBT session"))] - MissingDbtSession { - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Invalid auth data"))] InvalidAuthData { #[snafu(implicit)] @@ -82,14 +44,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Failed to parse row JSON"))] - RowParse { - #[snafu(source)] - error: serde_json::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("UTF8 error: {error}"))] Utf8 { #[snafu(source)] @@ -211,29 +165,14 @@ impl Error { _ => (http::StatusCode::OK, SqlState::Success, error_code), } } - Self::GZipDecompress { .. } - | Self::LoginRequestParse { .. } - | Self::QueryBodyParse { .. } - | Self::InvalidUuidFormat { .. } => { - // TODO: Is this need a fix? Bad request return retriable http code - ( - http::StatusCode::BAD_REQUEST, - SqlState::Success, - ErrorCode::Other, - ) - } Self::MissingAuthToken { .. } - | Self::MissingDbtSession { .. } | Self::InvalidAuthData { .. } | Self::InvalidAuthToken { .. } => ( http::StatusCode::UNAUTHORIZED, SqlState::Success, ErrorCode::Other, ), - Self::RowParse { .. } - | Self::Utf8 { .. } - | Self::Arrow { .. } - | Self::NotImplemented { .. } => { + Self::Utf8 { .. } | Self::Arrow { .. } | Self::NotImplemented { .. } => { (http::StatusCode::OK, SqlState::Success, ErrorCode::Other) } }; diff --git a/crates/catalog-metastore/src/error.rs b/crates/catalog-metastore/src/error.rs index 4e4072ff..a6c3b5fd 100644 --- a/crates/catalog-metastore/src/error.rs +++ b/crates/catalog-metastore/src/error.rs @@ -25,26 +25,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Volume: Validation failed. Reason: {reason}"))] - VolumeValidationFailed { - reason: String, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Volume: Missing credentials"))] - VolumeMissingCredentials { - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display("Cloud provider not implemented"))] - CloudProviderNotImplemented { - provider: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("ObjectStore: {error}"))] ObjectStore { #[snafu(source)] @@ -53,25 +33,6 @@ pub enum Error { location: Location, }, - #[snafu(display("ObjectStore path: {error}"))] - ObjectStorePath { - #[snafu(source)] - error: object_store::path::Error, - #[snafu(implicit)] - location: Location, - }, - - #[snafu(display( - "Unable to create directory for File ObjectStore path {path}, error: {error}" - ))] - CreateDirectory { - path: String, - #[snafu(source)] - error: std::io::Error, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Metastore object of type {type_name} with name {name} already exists"))] ObjectAlreadyExists { type_name: String, @@ -80,12 +41,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Metastore object not found"))] - ObjectNotFound { - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Volume {volume} already exists"))] VolumeAlreadyExists { volume: String, From 89c91f6af3d04d0f44ea9aa8a7f976af44d5afb3 Mon Sep 17 00:00:00 2001 From: Yaroslav Litvinov Date: Mon, 10 Nov 2025 18:49:01 +0100 Subject: [PATCH 2/2] remove unused code --- crates/catalog/src/lib.rs | 67 --------------------------------------- 1 file changed, 67 deletions(-) diff --git a/crates/catalog/src/lib.rs b/crates/catalog/src/lib.rs index e03f2aae..af316055 100644 --- a/crates/catalog/src/lib.rs +++ b/crates/catalog/src/lib.rs @@ -29,70 +29,3 @@ where .join() .unwrap_or_else(|_| error::ThreadPanickedWhileExecutingFutureSnafu.fail()?) } - -pub mod test_utils { - use datafusion::arrow::array::{ArrayRef, RecordBatch}; - use datafusion::arrow::compute::{ - SortColumn, SortOptions, lexsort_to_indices, take_record_batch, - }; - use datafusion::arrow::datatypes::{DataType, Field, Schema}; - use std::collections::HashSet; - use std::sync::Arc; - - #[allow(clippy::unwrap_used, clippy::must_use_candidate)] - pub fn sort_record_batch_by_sortable_columns(batch: &RecordBatch) -> RecordBatch { - let sort_columns: Vec = (0..batch.num_columns()) - .filter_map(|i| { - let col = batch.column(i).clone(); - let field = batch.schema().field(i).clone(); - if matches!(field.data_type(), DataType::Null) { - None - } else { - Some(SortColumn { - values: col, - options: Some(SortOptions::default()), - }) - } - }) - .collect(); - - if sort_columns.is_empty() { - return batch.clone(); - } - - let indices = lexsort_to_indices(&sort_columns, Some(batch.num_rows())).unwrap(); - take_record_batch(batch, &indices).unwrap() - } - - #[allow(clippy::unwrap_used, clippy::must_use_candidate)] - pub fn remove_columns_from_batches( - batches: Vec, - excluded_columns: &HashSet<&str, S>, - ) -> Vec { - batches - .into_iter() - .map(|batch| { - let schema = batch.schema(); - let indices: Vec = schema - .fields() - .iter() - .enumerate() - .filter_map(|(i, f)| { - if excluded_columns.contains(f.name().as_str()) { - None - } else { - Some(i) - } - }) - .collect(); - - let columns: Vec = - indices.iter().map(|&i| batch.column(i).clone()).collect(); - let fields: Vec = indices.iter().map(|&i| schema.field(i).clone()).collect(); - let new_schema = Arc::new(Schema::new(fields)); - - RecordBatch::try_new(new_schema, columns).unwrap() - }) - .collect() - } -}