Skip to content

Bug converting json to fixed list of zero size #9780

Description

@alamb

There's a fun little degenerate test case here:

    #[test]
    fn test_fixed_size_list_zero_size() {
        let buf = r#"
        {"a": []}
        {"a": null}
        {"a": []}
        "#;

        let field = Field::new_list_field(DataType::Int32, true);
        let schema = Arc::new(Schema::new(vec![Field::new(
            "a",
            DataType::FixedSizeList(Arc::new(field), 0),
            false,
        )]));

        let batches = do_read(buf, 1024, false, false, schema);
        assert_eq!(batches.len(), 1);

        let col = batches[0].column(0).as_fixed_size_list();
        assert_eq!(col.len(), 3);
        assert_eq!(col.value_length(), 0);

        let values = col.values().as_primitive::<Int32Type>();
        assert!(values.values().is_empty());
    }

It seems to panic within struct array decoding. Could be worth exploring in this PR if there is capacity, though considering this PR is adding a new feature I wouldn't block it on this case.

Originally posted by @Jefffrey in #9715 (review)

Metadata

Metadata

Assignees

Labels

arrowChanges to the arrow crate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions