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-optimizer crate #3314

Closed
andygrove opened this issue Sep 1, 2022 · 1 comment
Closed

Review use of panic in datafusion-optimizer crate #3314

andygrove opened this issue Sep 1, 2022 · 1 comment
Assignees
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/optimizer/src/common_subexpr_eliminate.rs":111                 new_expr.pop().unwrap(),
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":145                 predicate: new_expr.pop().unwrap().pop().unwrap(),
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":167                 window_expr: new_expr.pop().unwrap(),
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":189             let new_aggr_expr = new_expr.pop().unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":190             let new_group_expr = new_expr.pop().unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":212                 expr: new_expr.pop().unwrap(),
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":276         let (expr, _, data_type) = expr_set.get(&id).unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":557         unreachable!("Enter mark should paired with node number");
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":655         let (_, counter, _) = self.expr_set.get(curr_id).unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/common_subexpr_eliminate.rs":676             || self.expr_set.get(id).unwrap().1 <= 1
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/filter_push_down.rs":180         _ => unreachable!("lr_is_preserved only valid for JOIN nodes"),
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/filter_push_down.rs":195             JoinType::Semi | JoinType::Anti => unreachable!(
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/filter_push_down.rs":200             unreachable!("on_lr_is_preserved cannot be applied to CROSSJOIN nodes")
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/filter_push_down.rs":202         _ => unreachable!("on_lr_is_preserved only valid for JOIN nodes"),
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/filter_push_down.rs":314             .chain(once(on_to_keep.into_iter().reduce(Expr::and).unwrap()))
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/simplify_expressions.rs":172         _ => panic!("Expected boolean literal, got {:?}", expr),
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/simplify_expressions.rs":393         if self.can_evaluate.pop().unwrap() {
"/home/andy/git/apache/arrow-datafusion/datafusion/optimizer/src/single_distinct_to_groupby.rs":176                             fields_set.insert(expr.name(input.schema()).unwrap());

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
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-optimizer crate Review use of panic in datafusion-optimizer crate Sep 2, 2022
@andygrove andygrove self-assigned this Sep 2, 2022
@andygrove
Copy link
Member Author

These have all been resolved now.

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
Development

No branches or pull requests

1 participant