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

Review use of panic in datafusion-common crate #3313

Closed
andygrove opened this issue Sep 1, 2022 · 0 comments · Fixed by #7901
Closed

Review use of panic in datafusion-common crate #3313

andygrove opened this issue Sep 1, 2022 · 0 comments · Fixed by #7901
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@andygrove
Copy link
Member

andygrove commented Sep 1, 2022

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/from_slice.rs":68             length_so_far += OffsetSize::from_usize(s.len()).unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/pyarrow.rs":70         self.to_pyarrow(py).unwrap()
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":442         let array = $array.as_any().downcast_ref::<$ARRAYTYPE>().unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":455         let array = $array.as_any().downcast_ref::<$ARRAYTYPE>().unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":543                     _ => panic!("Incompatible ScalarValue for list"),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":566                     _ => panic!("Incompatible ScalarValue for list"),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":604         let array = $array.as_any().downcast_ref::<$ARRAYTYPE>().unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":730             _ => panic!("Cannot run arithmetic negate on scalar value: {:?}", self),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":892                                 sv => panic!(
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":900                         sv => panic!(
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1095                                 panic!("Expected inner key type of {} but found: {}, value was ({:?})", key_type, inner_key_type, scalar);
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1119                     _ => unreachable!("Invalid dictionary keys type: {:?}", key_type),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1151                     _ => unreachable!(),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1165                 _ => unreachable!(),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1244             .unwrap()
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1370                 .unwrap(),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1444                     _ => unreachable!("Invalid dictionary keys type: {:?}", key_type),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1457         let array = array.as_any().downcast_ref::<Decimal128Array>().unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1572                     _ => unreachable!("Invalid dictionary keys type: {:?}", key_type),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1605                     array.as_any().downcast_ref::<FixedSizeListArray>().unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1642         let array = array.as_any().downcast_ref::<Decimal128Array>().unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1711             ScalarValue::List(_, _) => unimplemented!(),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1742             ScalarValue::Struct(_, _) => unimplemented!(),
"/home/andy/git/apache/arrow-datafusion/datafusion/common/src/scalar.rs":1753                     _ => unreachable!("Invalid dictionary keys type: {:?}", key_type),

Describe the solution you'd like
Review code that can panic and see where it makes sense to return a Result instead. For example, It is generally better to use ? than unwrapon results.

The goal is not to remove all panics but review and make sure we are using them appropriately. Bonus points for adding documentation for invariants.

Describe alternatives you've considered
None

Additional context
List generated by https://github.com/andygrove/no-need-to-panic

@andygrove andygrove added enhancement New feature or request good first issue Good for newcomers labels Sep 1, 2022
@andygrove andygrove changed the title Remove panics from datafusion-common crate Review use of panic in datafusion-common crate Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
1 participant