Skip to content

Panic when creating empty table #1914

Description

@McPatate

Hello!

I've been running into some issues while creating a table with an empty batch record.

            let schema = Arc::new(Schema::new(vec![
                Field::new(
                    "vector",
                    DataType::FixedSizeList(
                        Arc::new(Field::new("item", DataType::Float32, true)),
                        768,
                    ),
                    false,
                ),
                Field::new("content", DataType::Utf8, false),
                Field::new("file_url", DataType::Utf8, false),
                Field::new("start_line_no", DataType::UInt32, false),
                Field::new("end_line_no", DataType::UInt32, false),
            ]));
            let batch = RecordBatch::try_new(
                schema.clone(),
                vec![
                    Arc::new(FixedSizeListBuilder::new(Float32Builder::new(), 768).finish()),
                    Arc::new(StringArray::from(Vec::<&str>::new())),
                    Arc::new(StringArray::from(Vec::<&str>::new())),
                    Arc::new(UInt32Array::from(Vec::<u32>::new())),
                    Arc::new(UInt32Array::from(Vec::<u32>::new())),
                ],
            )
            .expect("failure while defining schema");
            let tbl = db
                .create_table(
                    "code-slices",
                    Box::new(RecordBatchIterator::new(vec![batch].into_iter().map(Ok), schema)),
                    None,
                )
                .await
                .expect("failed to create table");
            tbl.create_index(&["vector"])
                .ivf_pq()
                .num_partitions(256)
                .build()
                .await
                .expect("failed to create index");

The statistics collector finish() method panics here when attempting to create a StructArray because "Found unmasked nulls for non-nullable StructArray field min_value".
If I instead remove batch and pass an empty vec![] to RecordBatchIterator::new, I get an error with the index creation that says it "can not train 256 centroids with 0 vectors".

Is there a way to initialise an empty table w/ an index with the Rust client?

Let me know if this isn't the right place to report this issue, I'll move it to the appropriate place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions