Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle when kernel returns a nullptr for the stats #89

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/functions/delta_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ static void visit_callback(ffi::NullableCvoid engine_context, struct ffi::Kernel
// Initialize the file metadata
context->metadata.back()->delta_snapshot_version = context->version;
context->metadata.back()->file_number = context->resolved_files.size() - 1;
context->metadata.back()->cardinality = stats->num_records;
if (stats) {
context->metadata.back()->cardinality = stats->num_records;
}

// Fetch the deletion vector
auto selection_vector_res = ffi::selection_vector_from_dv(dv_info, context->extern_engine.get(), context->global_state.get());
Expand Down Expand Up @@ -510,11 +512,19 @@ unique_ptr<NodeStatistics> DeltaSnapshot::GetCardinality(ClientContext &context)
}

idx_t total_tuple_count = 0;
bool have_any_stats = false;
for (auto &metadatum : metadata) {
total_tuple_count += metadatum->cardinality;
if (metadatum->cardinality != DConstants::INVALID_INDEX) {
have_any_stats = true;
total_tuple_count += metadatum->cardinality;
}
}

if (have_any_stats) {
return make_uniq<NodeStatistics>(total_tuple_count,total_tuple_count);
}

return make_uniq<NodeStatistics>(total_tuple_count,total_tuple_count);
return nullptr;
}

unique_ptr<MultiFileReader> DeltaMultiFileReader::CreateInstance() {
Expand Down
Loading