Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] thread through transport errors #2446

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/arrow2/src/io/parquet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ impl From<parquet2::error::Error> for Error {
.to_string();
Error::ExternalFormat(message)
}
parquet2::error::Error::Transport(msg) => {
Error::Io(std::io::Error::new(std::io::ErrorKind::Other, msg))
}
_ => Error::ExternalFormat(error.to_string()),
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/common/error/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ impl std::error::Error for DaftError {

impl From<arrow2::error::Error> for DaftError {
fn from(error: arrow2::error::Error) -> Self {
DaftError::ArrowError(error.to_string())
match error {
arrow2::error::Error::Io(_) => DaftError::ByteStreamError(error.into()),
_ => DaftError::ArrowError(error.to_string()),
}
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/parquet2/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub enum Error {
InvalidParameter(String),
/// When decoding or decompressing, the page would allocate more memory than allowed
WouldOverAllocate,
/// When a transport error occurs when reading data
Transport(String),
}

impl Error {
Expand Down Expand Up @@ -63,6 +65,9 @@ impl std::fmt::Display for Error {
Error::WouldOverAllocate => {
write!(fmt, "Operation would exceed memory use threshold")
}
Error::Transport(message) => {
write!(fmt, "Transport error: {}", message)
}
}
}
}
Expand Down Expand Up @@ -90,13 +95,18 @@ impl From<lz4_flex::block::CompressError> for Error {

impl From<parquet_format_safe::thrift::Error> for Error {
fn from(e: parquet_format_safe::thrift::Error) -> Error {
Error::OutOfSpec(format!("Invalid thrift: {}", e))
match e {
parquet_format_safe::thrift::Error::Transport(msg) => {
Error::Transport(format!("io error occurred when decoding thrift: {}", msg))
}
_ => Error::OutOfSpec(format!("Invalid thrift: {}", e)),
}
}
}

impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Error {
Error::OutOfSpec(format!("underlying IO error: {}", e))
Error::Transport(format!("underlying IO error: {}", e))
}
}

Expand Down
Loading