Skip to content

Review use of panic in datafusion-proto crate #3318

Closed

Description

@andygrove

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/proto/build.rs":33     let descriptor_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap())
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/build.rs":43     let descriptor_set = std::fs::read(descriptor_path).unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/build.rs":46         .unwrap()
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/bytes/mod.rs":140     let back: protobuf::LogicalPlanNode = serde_json::from_str(json).unwrap();
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/from_proto.rs":381                 .unwrap()
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/from_proto.rs":384                 .unwrap()
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/from_proto.rs":573                     field_names.last().unwrap().as_str(),
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/from_proto.rs":678             field_names.last().unwrap(),
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/from_proto.rs":1317         panic!("Expected a Vec of length {} but it was {}", N, v.len())
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/logical_plan.rs":418                     .map(|p| ListingTableUrl::parse(p).unwrap())
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/logical_plan.rs":656                 let mut builder = LogicalPlanBuilder::from(input_plans.pop().unwrap());
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/to_proto.rs":227                 unimplemented!("The Decimal256 data type is not yet supported")
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/to_proto.rs":230                 unimplemented!("The Map data type is not yet supported")
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/to_proto.rs":561             Expr::ScalarVariable(_, _) => unimplemented!(),
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/to_proto.rs":769                 unimplemented!("subquery expressions are not supported yet")
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/to_proto.rs":814             Expr::QualifiedWildcard { .. } | Expr::TryCast { .. } => unimplemented!(),
"/home/andy/git/apache/arrow-datafusion/datafusion/proto/src/to_proto.rs":911                                     todo!("Proper error handling {}", unsupported)

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

Activity

  1. changed the title [-]Remove panics from `datafusion-proto` crate[/-] [+]Review use of panic in `datafusion-proto` crate[/+] on Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions