Skip to content

Validity for array child vector returns null #571

@barsdeveloper

Description

@barsdeveloper

I have an issue with the C API, sorry I post it here but you might be able to understand rust better.

I am making a function to extract a value from the vector, I show you a fragment of code

pub(crate) fn extract_value(
    vector: duckdb_vector,
    row: usize,
    logical_type: duckdb_logical_type,
    type_id: u32,
    data: *const c_void,
    validity: *mut u64,
) -> Result<Value> {
    unsafe {
        let is_valid = /* !data.is_null() &&*/ duckdb_validity_row_is_valid(validity, row as u64);
        let result = match type_id {
            DUCKDB_TYPE_DUCKDB_TYPE_LIST | DUCKDB_TYPE_DUCKDB_TYPE_ARRAY => {
                let is_array = type_id == DUCKDB_TYPE_DUCKDB_TYPE_ARRAY;
                let (vector, child_logical_type) = if is_array {
                    (
                        duckdb_array_vector_get_child(vector), // Vector will be the child vector
                        duckdb_array_type_child_type(logical_type),
                    )
                } else {
                    (
                        duckdb_list_vector_get_child(vector),
                        duckdb_list_type_child_type(logical_type),
                    )
                };
                let child_logical_type = CBox::new(child_logical_type, |mut v| {
                    duckdb_destroy_logical_type(&mut v)
                });
                let type_id = duckdb_get_type_id(*child_logical_type);
                let data = duckdb_vector_get_data(vector);
                let validity = duckdb_vector_get_validity(vector); // Will be null

Basically everything seems alright except this validity, For example last type_id is correctly identified as 17: DUCKDB_TYPE_DUCKDB_TYPE_VARCHAR, element_type seems to correctly refer to the first character of this array of varchar: 'U'.

Does array allow individual elements to be null? Did I miss something?

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