Skip to content

Commit d545780

Browse files
remove unused error variants (#5)
* remove unused error variants * remove unused code
1 parent d616243 commit d545780

3 files changed

Lines changed: 1 addition & 174 deletions

File tree

crates/api-snowflake-rest/src/server/error.rs

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,6 @@ pub type Result<T> = std::result::Result<T, Error>;
2020
#[snafu(visibility(pub(crate)))]
2121
#[error_stack_trace::debug]
2222
pub enum Error {
23-
#[snafu(display("Failed to decompress GZip body"))]
24-
GZipDecompress {
25-
#[snafu(source)]
26-
error: std::io::Error,
27-
#[snafu(implicit)]
28-
location: Location,
29-
},
30-
31-
#[snafu(display("Failed to parse login request"))]
32-
LoginRequestParse {
33-
#[snafu(source)]
34-
error: serde_json::Error,
35-
#[snafu(implicit)]
36-
location: Location,
37-
},
38-
39-
#[snafu(display("Failed to parse query body"))]
40-
QueryBodyParse {
41-
#[snafu(source)]
42-
error: serde_json::Error,
43-
#[snafu(implicit)]
44-
location: Location,
45-
},
46-
4723
#[snafu(display("Missing auth token"))]
4824
MissingAuthToken {
4925
#[snafu(implicit)]
@@ -56,20 +32,6 @@ pub enum Error {
5632
location: Location,
5733
},
5834

59-
#[snafu(display("Invalid uuid format"))]
60-
InvalidUuidFormat {
61-
#[snafu(source)]
62-
error: uuid::Error,
63-
#[snafu(implicit)]
64-
location: Location,
65-
},
66-
67-
#[snafu(display("Missing DBT session"))]
68-
MissingDbtSession {
69-
#[snafu(implicit)]
70-
location: Location,
71-
},
72-
7335
#[snafu(display("Invalid auth data"))]
7436
InvalidAuthData {
7537
#[snafu(implicit)]
@@ -82,14 +44,6 @@ pub enum Error {
8244
location: Location,
8345
},
8446

85-
#[snafu(display("Failed to parse row JSON"))]
86-
RowParse {
87-
#[snafu(source)]
88-
error: serde_json::Error,
89-
#[snafu(implicit)]
90-
location: Location,
91-
},
92-
9347
#[snafu(display("UTF8 error: {error}"))]
9448
Utf8 {
9549
#[snafu(source)]
@@ -211,29 +165,14 @@ impl Error {
211165
_ => (http::StatusCode::OK, SqlState::Success, error_code),
212166
}
213167
}
214-
Self::GZipDecompress { .. }
215-
| Self::LoginRequestParse { .. }
216-
| Self::QueryBodyParse { .. }
217-
| Self::InvalidUuidFormat { .. } => {
218-
// TODO: Is this need a fix? Bad request return retriable http code
219-
(
220-
http::StatusCode::BAD_REQUEST,
221-
SqlState::Success,
222-
ErrorCode::Other,
223-
)
224-
}
225168
Self::MissingAuthToken { .. }
226-
| Self::MissingDbtSession { .. }
227169
| Self::InvalidAuthData { .. }
228170
| Self::InvalidAuthToken { .. } => (
229171
http::StatusCode::UNAUTHORIZED,
230172
SqlState::Success,
231173
ErrorCode::Other,
232174
),
233-
Self::RowParse { .. }
234-
| Self::Utf8 { .. }
235-
| Self::Arrow { .. }
236-
| Self::NotImplemented { .. } => {
175+
Self::Utf8 { .. } | Self::Arrow { .. } | Self::NotImplemented { .. } => {
237176
(http::StatusCode::OK, SqlState::Success, ErrorCode::Other)
238177
}
239178
};

crates/catalog-metastore/src/error.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,6 @@ pub enum Error {
2525
location: Location,
2626
},
2727

28-
#[snafu(display("Volume: Validation failed. Reason: {reason}"))]
29-
VolumeValidationFailed {
30-
reason: String,
31-
#[snafu(implicit)]
32-
location: Location,
33-
},
34-
35-
#[snafu(display("Volume: Missing credentials"))]
36-
VolumeMissingCredentials {
37-
#[snafu(implicit)]
38-
location: Location,
39-
},
40-
41-
#[snafu(display("Cloud provider not implemented"))]
42-
CloudProviderNotImplemented {
43-
provider: String,
44-
#[snafu(implicit)]
45-
location: Location,
46-
},
47-
4828
#[snafu(display("ObjectStore: {error}"))]
4929
ObjectStore {
5030
#[snafu(source)]
@@ -53,25 +33,6 @@ pub enum Error {
5333
location: Location,
5434
},
5535

56-
#[snafu(display("ObjectStore path: {error}"))]
57-
ObjectStorePath {
58-
#[snafu(source)]
59-
error: object_store::path::Error,
60-
#[snafu(implicit)]
61-
location: Location,
62-
},
63-
64-
#[snafu(display(
65-
"Unable to create directory for File ObjectStore path {path}, error: {error}"
66-
))]
67-
CreateDirectory {
68-
path: String,
69-
#[snafu(source)]
70-
error: std::io::Error,
71-
#[snafu(implicit)]
72-
location: Location,
73-
},
74-
7536
#[snafu(display("Metastore object of type {type_name} with name {name} already exists"))]
7637
ObjectAlreadyExists {
7738
type_name: String,
@@ -80,12 +41,6 @@ pub enum Error {
8041
location: Location,
8142
},
8243

83-
#[snafu(display("Metastore object not found"))]
84-
ObjectNotFound {
85-
#[snafu(implicit)]
86-
location: Location,
87-
},
88-
8944
#[snafu(display("Volume {volume} already exists"))]
9045
VolumeAlreadyExists {
9146
volume: String,

crates/catalog/src/lib.rs

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -29,70 +29,3 @@ where
2929
.join()
3030
.unwrap_or_else(|_| error::ThreadPanickedWhileExecutingFutureSnafu.fail()?)
3131
}
32-
33-
pub mod test_utils {
34-
use datafusion::arrow::array::{ArrayRef, RecordBatch};
35-
use datafusion::arrow::compute::{
36-
SortColumn, SortOptions, lexsort_to_indices, take_record_batch,
37-
};
38-
use datafusion::arrow::datatypes::{DataType, Field, Schema};
39-
use std::collections::HashSet;
40-
use std::sync::Arc;
41-
42-
#[allow(clippy::unwrap_used, clippy::must_use_candidate)]
43-
pub fn sort_record_batch_by_sortable_columns(batch: &RecordBatch) -> RecordBatch {
44-
let sort_columns: Vec<SortColumn> = (0..batch.num_columns())
45-
.filter_map(|i| {
46-
let col = batch.column(i).clone();
47-
let field = batch.schema().field(i).clone();
48-
if matches!(field.data_type(), DataType::Null) {
49-
None
50-
} else {
51-
Some(SortColumn {
52-
values: col,
53-
options: Some(SortOptions::default()),
54-
})
55-
}
56-
})
57-
.collect();
58-
59-
if sort_columns.is_empty() {
60-
return batch.clone();
61-
}
62-
63-
let indices = lexsort_to_indices(&sort_columns, Some(batch.num_rows())).unwrap();
64-
take_record_batch(batch, &indices).unwrap()
65-
}
66-
67-
#[allow(clippy::unwrap_used, clippy::must_use_candidate)]
68-
pub fn remove_columns_from_batches<S: ::std::hash::BuildHasher>(
69-
batches: Vec<RecordBatch>,
70-
excluded_columns: &HashSet<&str, S>,
71-
) -> Vec<RecordBatch> {
72-
batches
73-
.into_iter()
74-
.map(|batch| {
75-
let schema = batch.schema();
76-
let indices: Vec<usize> = schema
77-
.fields()
78-
.iter()
79-
.enumerate()
80-
.filter_map(|(i, f)| {
81-
if excluded_columns.contains(f.name().as_str()) {
82-
None
83-
} else {
84-
Some(i)
85-
}
86-
})
87-
.collect();
88-
89-
let columns: Vec<ArrayRef> =
90-
indices.iter().map(|&i| batch.column(i).clone()).collect();
91-
let fields: Vec<Field> = indices.iter().map(|&i| schema.field(i).clone()).collect();
92-
let new_schema = Arc::new(Schema::new(fields));
93-
94-
RecordBatch::try_new(new_schema, columns).unwrap()
95-
})
96-
.collect()
97-
}
98-
}

0 commit comments

Comments
 (0)