Skip to content

[Variant] Panic when appending Object or List to VariantBuilder #7701

@alamb

Description

@alamb

Describe the bug
The VariantBuilder code will panic if you try and append an existing Object or LIst

To Reproduce
Add this test to parquet-variant/src/builder.rs"

    #[test]
    fn test_append_object() {
        let (object_metadata, object_value) = {
            let mut builder = VariantBuilder::new();
            let mut obj = builder.new_object();
            obj.append_value("name", "John");
            obj.finish();
            builder.finish()
        };
        let object_variant = Variant::try_new(&object_metadata, &object_value).unwrap();

        let mut builder = VariantBuilder::new();
        builder.append_value(object_variant.clone());
        let (metadata, value) = builder.finish();
        let variant = Variant::try_new(&metadata, &value).unwrap();
        assert_eq!(variant, object_variant);
    }
}

This results in

internal error: entered unreachable code: Object and List variants cannot be created through Into<Variant>
thread 'builder::tests::test_append_object' panicked at parquet-variant/src/builder.rs:395:17:

Expected behavior
I expect the object variant to be copied to the in progress builder

Additional context

Metadata

Metadata

Assignees

Labels

bugparquetChanges to the parquet crate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions