You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Marc Prud'hommeaux (Jira)" <ji...@apache.org> on 2021/02/10 18:46:00 UTC

[jira] [Created] (ARROW-11586) [Rust] [Datafusion] Invalid SQL sometimes panics

Marc Prud'hommeaux created ARROW-11586:
------------------------------------------

             Summary: [Rust] [Datafusion] Invalid SQL sometimes panics
                 Key: ARROW-11586
                 URL: https://issues.apache.org/jira/browse/ARROW-11586
             Project: Apache Arrow
          Issue Type: Bug
            Reporter: Marc Prud'hommeaux


Executing the invalid SQL "select 1 order by x" will panic rather returning an Err:

 ```
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Plan("Invalid identifier \'x\' for schema Int64(1)")', /Users/marc/.cargo/git/checkouts/arrow-3a9cfebb6b7b2bdc/643f420/rust/datafusion/src/sql/planner.rs:649:76
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_none_failed
   3: core::result::Result<T,E>::unwrap
   4: datafusion::sql::planner::SqlToRel<S>::order_by::{{closure}}
   5: core::iter::adapters::map_try_fold::{{closure}}
   6: core::iter::traits::iterator::Iterator::try_fold
   7: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
   8: <core::iter::adapters::ResultShunt<I,E> as core::iter::traits::iterator::Iterator>::try_fold
   9: core::iter::traits::iterator::Iterator::find
  10: <core::iter::adapters::ResultShunt<I,E> as core::iter::traits::iterator::Iterator>::next
  11: <alloc::vec::Vec<T> as alloc::vec::SpecFromIterNested<T,I>>::from_iter
  12: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
  13: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
  14: core::iter::traits::iterator::Iterator::collect
  15: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter::{{closure}}
  16: core::iter::adapters::process_results
  17: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter
  18: core::iter::traits::iterator::Iterator::collect
  19: datafusion::sql::planner::SqlToRel<S>::order_by
  20: datafusion::sql::planner::SqlToRel<S>::query_to_plan
  21: datafusion::sql::planner::SqlToRel<S>::sql_statement_to_plan
  22: datafusion::sql::planner::SqlToRel<S>::statement_to_plan
  23: datafusion::execution::context::ExecutionContext::create_logical_plan
```

This is happening because of an `unwrap` at https://github.com/apache/arrow/blob/6cfbd22b457d873365fa60df31905857856608ee/rust/datafusion/src/sql/planner.rs#L652. 

Perhaps the error should be returned as the Result rather than panicking, so the error can be handled? There are a number of other places in the planner where `unwrap()` is used, so they may warrant similar treatment.
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)