You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "dvic (via GitHub)" <gi...@apache.org> on 2024/01/24 23:00:46 UTC
[I] Cannot write parquet file with list of non-nullable item [arrow-rs]
dvic opened a new issue, #5330:
URL: https://github.com/apache/arrow-rs/issues/5330
**Describe the bug**
When I try to write a `non-null List<non-null i32>` to a parquet file, I get an error. Might be related to #385.
**To Reproduce**
```rust
use std::{error::Error, fs::File, sync::Arc};
use ::arrow::record_batch::RecordBatch;
use arrow::{
array::{Int32Builder, ListBuilder},
datatypes::{DataType, Field, Schema},
};
use parquet::arrow::arrow_writer::ArrowWriter;
pub fn main() -> Result<(), Box<dyn Error>> {
let mut builder = ListBuilder::new(Int32Builder::new());
builder.append_value([Some(1), Some(2), Some(3)]);
let array = builder.finish();
let inner_nullable = false;
let schema = Arc::new(Schema::new(vec![Field::new_list(
"col_a",
Field::new_list_field(DataType::Int32, inner_nullable),
false,
)]));
let batch = RecordBatch::try_new(schema, vec![Arc::new(array)])?;
let buf = File::create("test.parquet")?;
let mut writer = ArrowWriter::try_new(buf, batch.schema(), None)?;
writer.write(&batch)?;
writer.close()?;
Ok(())
}
```
**Expected behavior**
I expect no errors, but instead I get:
```
Error: InvalidArgumentError("column types must match schema types,
expected
List(Field { name: \"item\", data_type: Int32, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} })
but found
List(Field { name: \"item\", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })
at column index 0")
```
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Cannot write parquet file with list of non-nullable item [arrow-rs]
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5330:
URL: https://github.com/apache/arrow-rs/issues/5330#issuecomment-1909090995
This is actually a known limitation of ListBuilder, where it can only produce nullable lists. I think there is already an issue about this, but I can't find it.
You will need to use the ListArray constructors, potentially with the components produced by ListBuilder
--
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
Re: [I] Support Creating Non-Nullable Lists with ListBuilder [arrow-rs]
Posted by "dvic (via GitHub)" <gi...@apache.org>.
dvic commented on issue #5330:
URL: https://github.com/apache/arrow-rs/issues/5330#issuecomment-1909715115
> Edit: the feature is actually pretty straightforward so bashed it out in #5331
Thanks! I actually just wanted to propose something like this :) (I saw the todo line at https://docs.rs/arrow-array/50.0.0/src/arrow_array/builder/generic_list_builder.rs.html#313)
--
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
Re: [I] Support Creating Non-Nullable Lists with ListBuilder [arrow-rs]
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold closed issue #5330: Support Creating Non-Nullable Lists with ListBuilder
URL: https://github.com/apache/arrow-rs/issues/5330
--
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
Re: [I] Support Creating Non-Nullable Lists with ListBuilder [arrow-rs]
Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5330:
URL: https://github.com/apache/arrow-rs/issues/5330#issuecomment-1972589422
`label_issue.py` automatically added labels {'arrow'} from #5331
--
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