-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Avoid panics on error while encoding/decoding ListValue::Array as protobuf #7837
Conversation
|
||
// TODO: Add comment to why adding 0 before arrow_data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 0 was added in the arrow.rs code as it was a test for unaligned data. The zero is not needed for this cod
cc @jayzhan211
@@ -56,13 +56,6 @@ use datafusion_expr::{ | |||
pub enum Error { | |||
General(String), | |||
|
|||
InconsistentListTyping(DataType, DataType), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variants are no longer used
@@ -655,29 +656,36 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue { | |||
let schema: Schema = if let Some(schema_ref) = schema { | |||
schema_ref.try_into()? | |||
} else { | |||
return Err(Error::General("Unexpected schema".to_string())); | |||
return Err(Error::General( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return some of Datafusion Errors instead? Maybe IoError
or InternalError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why the from_proto and to_proto modules have their own error types and don't use DataFusionError
(or even wrap DataFusionError
)
It does seem like that would be an improvement. Maybe I can file a follow on ticket to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks, @alamb !
Which issue does this PR close?
Follow on to #7629
Rationale for this change
I noticed some panics while reviewing #7629 from @jayzhan211 but I didn't want to delay merging that PR any longer.
What changes are included in this PR?
This commit avoids panics in the error handling in the ScalarValue::List protobuf encoding by using the
?
operatorinstead unwrap. It also removes some unused variants that are no longer used after
#7629
Are these changes tested?
By existing tests and the rust compiler
Are there any user-facing changes?
Less panics on bad data