You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Ameya Vikram (Jira)" <ji...@apache.org> on 2021/11/22 06:41:00 UTC

[jira] [Created] (ARROW-14785) [Rust] Support writing dictionaries nested in a list to IPC stream

Ameya Vikram created ARROW-14785:
------------------------------------

             Summary: [Rust] Support writing dictionaries nested in a list to IPC stream
                 Key: ARROW-14785
                 URL: https://issues.apache.org/jira/browse/ARROW-14785
             Project: Apache Arrow
          Issue Type: Bug
          Components: Rust
            Reporter: Ameya Vikram


Attempting to write/read dictionaries nested in a list to an IPC stream results in an error:
{code:java}
fn send_receive() -> std::result::Result<(), Box<dyn std::error::Error>> {
    let fields_vec = vec!["fields1", "fields2"];
    let fields_list = {
            let mut b = ListBuilder::with_capacity(StringDictionaryBuilder::new(PrimitiveBuilder::<Int32Type>::new(2), StringBuilder::new(2)), 1);
            for f in &fields_vec {
                b.values().append(f).unwrap();
                }
            b.append(true)?;
            b.finish()
        };
    let schema = Arc::new(Schema::new(vec![Field::new("fields", fields_list.data_type().clone(), false)]));
    let batch = RecordBatch::try_new(schema.clone(),vec![Arc::new(fields_list)])?;
    let buf = Vec::with_capacity(1024 * 32);
    let mut writer = arrow::ipc::writer::StreamWriter::try_new(buf, &schema)?;
    writer.write(&batch)?;
    writer.finish()?;    let reader = &writer.into_inner()?[..];
    let mut reader = arrow::ipc::reader::StreamReader::try_new(reader)?;
    while let Some(n) = reader.next() {
        let b = n?;
        println!("Parsed batch: {:?}", b);
    }
    Ok(())
}

fn main() {
    println!("Sending DictionaryArray in a list");
    match send_receive() {
        Ok(_) => println!("Encoded and decoded successfully"),
        Err(e) => panic!("{:?}", e)
    }
} {code}
The error:
{code:java}
Sending DictionaryArray in a list
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', .cargo/registry/src/github.com-1ecc6299db9ec823/arrow-6.2.0/src/ipc/reader.rs:176:31
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: arrow::ipc::reader::create_array
             at .cargo/registry/src/github.com-1ecc6299db9ec823/arrow-6.2.0/src/ipc/reader.rs:176:31
   4: arrow::ipc::reader::create_array
             at .cargo/registry/src/github.com-1ecc6299db9ec823/arrow-6.2.0/src/ipc/reader.rs:100:26
   5: arrow::ipc::reader::read_record_batch
             at .cargo/registry/src/github.com-1ecc6299db9ec823/arrow-6.2.0/src/ipc/reader.rs:432:22
   6: arrow::ipc::reader::StreamReader<R>::maybe_next
             at .cargo/registry/src/github.com-1ecc6299db9ec823/arrow-6.2.0/src/ipc/reader.rs:875:17
   7: <arrow::ipc::reader::StreamReader<R> as core::iter::traits::iterator::Iterator>::next
             at .cargo/registry/src/github.com-1ecc6299db9ec823/arrow-6.2.0/src/ipc/reader.rs:908:9
   8: rust_arrow::send_receive
             at ./src/main.rs:58:25
   9: rust_arrow::main
             at ./src/main.rs:81:11{code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)