diff --git a/delta-kernel-rs b/delta-kernel-rs index b9aa38c..663585d 160000 --- a/delta-kernel-rs +++ b/delta-kernel-rs @@ -1 +1 @@ -Subproject commit b9aa38cd69e2a7e5045c63d5b238d889e8eb83aa +Subproject commit 663585d1940b01ecddf5edabb63cb70df7bc7add diff --git a/duckdb b/duckdb index bb927be..3ed5d83 160000 --- a/duckdb +++ b/duckdb @@ -1 +1 @@ -Subproject commit bb927beb445c8c0f16f9164cf2eb5c3cf2239886 +Subproject commit 3ed5d833dd95556c0a4f88175f4bf9722f978b9e diff --git a/src/functions/deltatable_scan.cpp b/src/functions/deltatable_scan.cpp index 0e05641..21af9b5 100644 --- a/src/functions/deltatable_scan.cpp +++ b/src/functions/deltatable_scan.cpp @@ -50,8 +50,8 @@ static void visit_callback(ffi::NullableCvoid engine_context, const struct ffi:: // Fetch the deletion vector auto selection_vector_res = ffi::selection_vector_from_dv(dv_info, context->table_client, context->global_state); auto selection_vector = unpack_result_or_throw(selection_vector_res, "selection_vector_from_dv for path " + context->GetPath()); - if (selection_vector) { - context->metadata.back().selection_vector = {selection_vector, ffi::drop_bool_slice}; + if (selection_vector.ptr) { + context->metadata.back().selection_vector = selection_vector; } // Lookup all columns for potential hits in the constant map @@ -370,7 +370,7 @@ unique_ptr DeltaMultiFileReader::CreateFileList(ClientContext &co // Generate the correct Selection Vector Based on the Raw delta KernelBoolSlice dv and the row_id_column // TODO: this probably is slower than needed (we can do with less branches in the for loop for most cases) -static SelectionVector DuckSVFromDeltaSV(ffi::KernelBoolSlice *dv, Vector row_id_column, idx_t count, idx_t &select_count) { +static SelectionVector DuckSVFromDeltaSV(const ffi::KernelBoolSlice &dv, Vector row_id_column, idx_t count, idx_t &select_count) { D_ASSERT(row_id_column.GetType() == LogicalType::BIGINT); UnifiedVectorFormat data; @@ -383,7 +383,7 @@ static SelectionVector DuckSVFromDeltaSV(ffi::KernelBoolSlice *dv, Vector row_id auto row_id = row_ids[data.sel->get_index(i)]; // TODO: why are deletion vectors not spanning whole data? - if (row_id >= dv->len || dv->ptr[row_id]) { + if (row_id >= dv.len || dv.ptr[row_id]) { result.data()[current_select] = i; current_select++; } @@ -513,13 +513,13 @@ void DeltaMultiFileReader::FinalizeChunk(ClientContext &context, const MultiFile const auto &snapshot = dynamic_cast(*global_state->file_list); auto &metadata = snapshot.metadata[reader_data.file_list_idx.GetIndex()]; - if (metadata.selection_vector.get() && chunk.size() != 0) { + if (metadata.selection_vector.ptr && chunk.size() != 0) { D_ASSERT(delta_global_state.file_row_number_idx != DConstants::INVALID_INDEX); auto &file_row_number_column = chunk.data[delta_global_state.file_row_number_idx]; // Construct the selection vector using the file_row_number column and the raw selection vector from delta idx_t select_count; - auto sv = DuckSVFromDeltaSV(metadata.selection_vector.get(), file_row_number_column, chunk.size(), select_count); + auto sv = DuckSVFromDeltaSV(metadata.selection_vector, file_row_number_column, chunk.size(), select_count); chunk.Slice(sv, select_count); } diff --git a/src/include/functions/deltatable_scan.hpp b/src/include/functions/deltatable_scan.hpp index 35923f2..12cd795 100644 --- a/src/include/functions/deltatable_scan.hpp +++ b/src/include/functions/deltatable_scan.hpp @@ -14,11 +14,15 @@ namespace duckdb { struct DeltaFileMetaData { + ~DeltaFileMetaData() { + if (selection_vector.ptr) { + ffi::drop_bool_slice(selection_vector); + } + } + idx_t delta_snapshot_version; idx_t file_number; - - UniqueKernelPointer selection_vector; - + ffi::KernelBoolSlice selection_vector = {nullptr, 0}; case_insensitive_map_t partition_map; };