You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "BubbaJoe (via GitHub)" <gi...@apache.org> on 2023/03/18 12:52:05 UTC

[GitHub] [arrow-datafusion] BubbaJoe commented on issue #5635: Unable to "GROUP BY" udf result

BubbaJoe commented on issue #5635:
URL: https://github.com/apache/arrow-datafusion/issues/5635#issuecomment-1474842469

   
   I updated from 15.0 to 20.0 and something really weird happened. when i run this:
   `SELECT COUNT(*), T, SUM(COUNT(*)) Over (Order By T) From (SELECT *, to_date(\"updatedAt\") as T from 'table') Group BY T`
   I get the below error, this query was working fine on version 15.0
   
   I modified my UDF to process multiple values:
   ```
   pub fn to_date(args: &[ArrayRef]) -> DFResult<ArrayRef> {
       if args.is_empty() || args.len() > 1 {
           return Err(DataFusionError::Internal(format!(
               "to_date was called with {} arguments. It requires only 1.",
               args.len()
           )));
       }
       let arg = &args[0].as_any().downcast_ref::<StringArray>().unwrap();
       let mut builder = Date32Builder::new();
       for date_string in arg.iter() {
           let date_time = match DateTime::parse_from_rfc3339(date_string.expect("date_string is null")) {
               Ok(dt) => dt,
               Err(e) => {
                   return Result::Err(DataFusionError::Internal(e.to_string()));
               }
           };
           builder.append_value((date_time.timestamp() / 86400) as i32);
       }
       Ok(Arc::new(builder.finish()))
   }
   ```
   
   Error log:
   ```
   thread 'tokio-runtime-worker' panicked at 'Trying to access an element at index 17 from a PrimitiveArray of length 17', /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-array-34.0.0/src/array/primitive_array.rs:337:9
   stack backtrace:
      0: rust_begin_unwind
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
      1: core::panicking::panic_fmt
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
      2: arrow_array::array::primitive_array::PrimitiveArray<T>::value
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-array-34.0.0/src/array/primitive_array.rs:337:9
      3: <&arrow_array::array::primitive_array::PrimitiveArray<T> as arrow_array::array::ArrayAccessor>::value
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-array-34.0.0/src/array/primitive_array.rs:711:9
      4: <&arrow_array::array::primitive_array::PrimitiveArray<arrow_array::types::Date32Type> as arrow_cast::display::DisplayIndexState>::write
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-cast-34.0.0/src/display.rs:505:29
      5: <arrow_cast::display::ArrayFormat<F> as arrow_cast::display::DisplayIndex>::write
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-cast-34.0.0/src/display.rs:361:9
      6: <arrow_cast::display::ValueFormatter as core::fmt::Display>::fmt
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-cast-34.0.0/src/display.rs:162:15
      7: <T as alloc::string::ToString>::to_string
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/alloc/src/string.rs:2536:9
      8: arrow_json::writer::set_column_for_json_rows::{{closure}}
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-json-34.0.0/src/writer.rs:309:25
      9: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/iter/traits/iterator.rs:828:29
     10: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold::enumerate::{{closure}}
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/iter/adapters/enumerate.rs:106:27
     11: core::iter::traits::iterator::Iterator::fold
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/iter/traits/iterator.rs:2414:21
     12: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/iter/adapters/enumerate.rs:112:9
     13: core::iter::traits::iterator::Iterator::for_each
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/iter/traits/iterator.rs:831:9
     14: arrow_json::writer::set_column_for_json_rows
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-json-34.0.0/src/writer.rs:305:13
     15: arrow_json::writer::record_batches_to_json_rows
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/arrow-json-34.0.0/src/writer.rs:422:17
     16: dataqueen_back::routes::query::QueryResponse::new::{{closure}}
                at ./src/routes/query.rs:49:19
     17: dataqueen_back::routes::query::execute_query::{{closure}}
                at ./src/routes/query.rs:22:9
     18: <F as axum::handler::Handler<(M,T1,T2),S,B>>::call::{{closure}}
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.6.0-rc.4/src/handler/mod.rs:209:52
     19: <core::pin::Pin<P> as core::future::future::Future>::poll
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/future/future.rs:124:9
     20: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/map.rs:55:37
     21: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     22: <axum::handler::future::IntoServiceFuture<F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.6.0-rc.4/src/macros.rs:42:17
     23: <F as futures_core::future::TryFuture>::try_poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.25/src/future.rs:82:9
     24: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/try_future/into_future.rs:34:9
     25: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/map.rs:55:37
     26: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     27: <futures_util::future::try_future::MapOk<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     28: <tower::util::map_response::MapResponseFuture<F,N> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/macros.rs:38:17
     29: <core::pin::Pin<P> as core::future::future::Future>::poll
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/future/future.rs:124:9
     30: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/util/oneshot.rs:97:38
     31: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.6.0-rc.4/src/routing/route.rs:144:61
     32: <tower_http::cors::ResponseFuture<F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-http-0.3.4/src/cors/mod.rs:662:56
     33: <F as futures_core::future::TryFuture>::try_poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.25/src/future.rs:82:9
     34: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/try_future/into_future.rs:34:9
     35: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/map.rs:55:37
     36: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     37: <futures_util::future::try_future::MapOk<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     38: <tower::util::map_response::MapResponseFuture<F,N> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/macros.rs:38:17
     39: <F as futures_core::future::TryFuture>::try_poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.25/src/future.rs:82:9
     40: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/try_future/into_future.rs:34:9
     41: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/map.rs:55:37
     42: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     43: <futures_util::future::try_future::MapErr<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     44: <tower::util::map_err::MapErrFuture<F,N> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/macros.rs:38:17
     45: <F as futures_core::future::TryFuture>::try_poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.25/src/future.rs:82:9
     46: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/try_future/into_future.rs:34:9
     47: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/map.rs:55:37
     48: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     49: <futures_util::future::try_future::MapOk<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     50: <tower::util::map_response::MapResponseFuture<F,N> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/macros.rs:38:17
     51: <F as futures_core::future::TryFuture>::try_poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.25/src/future.rs:82:9
     52: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/try_future/into_future.rs:34:9
     53: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/map.rs:55:37
     54: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     55: <futures_util::future::try_future::MapOk<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     56: <tower::util::map_response::MapResponseFuture<F,N> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/macros.rs:38:17
     57: <core::pin::Pin<P> as core::future::future::Future>::poll
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/future/future.rs:124:9
     58: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/util/oneshot.rs:97:38
     59: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.6.0-rc.4/src/routing/route.rs:144:61
     60: <F as futures_core::future::TryFuture>::try_poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.25/src/future.rs:82:9
     61: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/try_future/into_future.rs:34:9
     62: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/future/future/map.rs:55:37
     63: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     64: <futures_util::future::try_future::MapOk<Fut,F> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.25/src/lib.rs:91:13
     65: <tower::util::map_response::MapResponseFuture<F,N> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/macros.rs:38:17
     66: <core::pin::Pin<P> as core::future::future::Future>::poll
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/future/future.rs:124:9
     67: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tower-0.4.13/src/util/oneshot.rs:97:38
     68: <axum::routing::route::RouteFuture<B,E> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/axum-0.6.0-rc.4/src/routing/route.rs:144:61
     69: <hyper::proto::h1::dispatch::Server<S,hyper::body::body::Body> as hyper::proto::h1::dispatch::Dispatch>::poll_msg
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/proto/h1/dispatch.rs:491:35
     70: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_write
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/proto/h1/dispatch.rs:297:43
     71: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/proto/h1/dispatch.rs:161:21
     72: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_inner
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/proto/h1/dispatch.rs:137:16
     73: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_catch
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/proto/h1/dispatch.rs:120:28
     74: <hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/proto/h1/dispatch.rs:424:9
     75: <hyper::server::conn::ProtoServer<T,B,S,E> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/server/conn.rs:952:47
     76: <hyper::server::conn::upgrades::UpgradeableConnection<I,S,E> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/server/conn.rs:1012:30
     77: <hyper::server::server::new_svc::NewSvcTask<I,N,S,E,W> as core::future::future::Future>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/server/server.rs:728:36
     78: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/task/core.rs:223:17
     79: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/loom/std/unsafe_cell.rs:14:9
     80: tokio::runtime::task::core::Core<T,S>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/task/core.rs:212:13
     81: tokio::runtime::task::harness::poll_future::{{closure}}
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/task/harness.rs:476:19
     82: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panic/unwind_safe.rs:271:9
     83: std::panicking::try::do_call
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:483:40
     84: ___rust_try
     85: std::panicking::try
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:447:19
     86: std::panic::catch_unwind
                at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panic.rs:137:14
     87: tokio::runtime::task::harness::poll_future
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/task/harness.rs:464:18
     88: tokio::runtime::task::harness::Harness<T,S>::poll_inner
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/task/harness.rs:198:27
     89: tokio::runtime::task::harness::Harness<T,S>::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/task/harness.rs:152:15
     90: tokio::runtime::task::raw::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/task/raw.rs:255:5
     91: tokio::runtime::task::raw::RawTask::poll
                at /Users/joe/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/task/raw.rs:200:18
   note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org