This project has brought me quite close to realizing a new extension of DuckDB.
I'm using duckdb-rs@919f145 with features = ["bundled", "vtab-loadable"] on a 2022 M2 Mac.
In a VTab::func implementation, I would like to update a structured column. That's easy enough -- get the column and then get its subcolumns and update each one. However, something goes wrong when calling StructVector.child()
Assertion failed: (dynamic_cast<TARGET *>(this)), function Cast, file vector_buffer.hpp, line 132.
Abort trap: 6
This function just calls duckdb_struct_vector_get_child, though, so it's hard to see how there could be anything wrong with it. That function ultimately delegates to StructVector::GetEntries (in C++). Inserting std::cout << ... lines indicates that all the types are as expected:
vector.GetType().id() is 100, equal to LogicalTypeId::STRUCT
vector.auxiliary->GetBufferType() is 5, equal to VectorBufferType::STRUCT_BUFFER
However, the call to vector.auxiliary->Cast<VectorStructBuffer>() fails. It turns out there is a dynamic cast in that function, as a kind of assert:
D_ASSERT(dynamic_cast<TARGET *>(this));
This is what is failing. Commenting it out seems to lead to no problems. Then I am able to get the flat buffers and add data to them (with Inserter or using .set_null(), &c) and query the results in DuckDB.
This project has brought me quite close to realizing a new extension of DuckDB.
I'm using duckdb-rs@919f145 with
features = ["bundled", "vtab-loadable"]
on a 2022 M2 Mac.In a
VTab::func
implementation, I would like to update a structured column. That's easy enough -- get the column and then get its subcolumns and update each one. However, something goes wrong when callingStructVector.child()
This function just calls
duckdb_struct_vector_get_child
, though, so it's hard to see how there could be anything wrong with it. That function ultimately delegates toStructVector::GetEntries
(in C++). Insertingstd::cout << ...
lines indicates that all the types are as expected:vector.GetType().id()
is 100, equal toLogicalTypeId::STRUCT
vector.auxiliary->GetBufferType()
is 5, equal toVectorBufferType::STRUCT_BUFFER
However, the call to
vector.auxiliary->Cast<VectorStructBuffer>()
fails. It turns out there is a dynamic cast in that function, as a kind of assert:This is what is failing. Commenting it out seems to lead to no problems. Then I am able to get the flat buffers and add data to them (with
Inserter
or using.set_null()
, &c) and query the results in DuckDB.This recent commit may be related: https://github.com/duckdb/duckdb/commit/837211d985ae485d09b8df18f58bf794a6857219