Skip to content

casting list to 0-size fixedsizelist can cause incorrect output length #10227

Description

@Jefffrey

Describe the bug

    #[test]
    fn test_cast_list_to_zero_size_fsl() {
        let field = Arc::new(Field::new("a", DataType::Null, true));
        let length = 2;
        let expected = Arc::new(
            FixedSizeListArray::try_new_with_length(
                field.clone(),
                0,
                new_empty_array(&DataType::Null),
                None,
                2,
            )
            .unwrap(),
        ) as ArrayRef;

        let list = Arc::new(ListArray::new(
            field.clone(),
            OffsetBuffer::from_repeated_length(0, length),
            new_empty_array(&DataType::Null),
            None,
        ));
        let fsl = cast(list.as_ref(), expected.data_type()).unwrap();
        assert_eq!(&expected, &fsl);
    }
  • this fails because output fixedsizelist has 0 length

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions