Skip to content

Commit

Permalink
vendor: Update vendored sources to duckdb/duckdb@cb8ecb6 (#1003)
Browse files Browse the repository at this point in the history
Index scan on (dynamic) table filters (duckdb/duckdb#15410)

Co-authored-by: krlmlr <[email protected]>
  • Loading branch information
github-actions[bot] and krlmlr authored Jan 10, 2025
1 parent 2c72011 commit eeb938d
Show file tree
Hide file tree
Showing 12 changed files with 530 additions and 341 deletions.
2 changes: 2 additions & 0 deletions src/duckdb/src/execution/index/art/art.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ unique_ptr<IndexScanState> ART::TryInitializeScan(const Expression &expr, const

// Try to find a matching index for any of the filter expressions.
ComparisonExpressionMatcher matcher;

// Match on a comparison type.
matcher.expr_type = make_uniq<ComparisonExpressionTypeMatcher>();

// Match on a constant comparison with the indexed expression.
matcher.matchers.push_back(make_uniq<ExpressionEqualityMatcher>(expr));
matcher.matchers.push_back(make_uniq<ConstantExpressionMatcher>());
Expand Down
7 changes: 5 additions & 2 deletions src/duckdb/src/execution/operator/join/physical_hash_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,14 @@ void JoinFilterPushdownInfo::PushInFilter(const JoinFilterPushdownFilter &info,
}

// generate the OR filter
auto or_filter = make_uniq<InFilter>(std::move(in_list));
auto in_filter = make_uniq<InFilter>(std::move(in_list));
in_filter->origin_is_hash_join = true;

// we push the OR filter as an OptionalFilter so that we can use it for zonemap pruning only
// the IN-list is expensive to execute otherwise
auto filter = make_uniq<OptionalFilter>(std::move(or_filter));
auto filter = make_uniq<OptionalFilter>(std::move(in_filter));
info.dynamic_filters->PushFilter(op, filter_col_idx, std::move(filter));
return;
}

unique_ptr<DataChunk> JoinFilterPushdownInfo::Finalize(ClientContext &context, JoinHashTable &ht,
Expand Down
30 changes: 17 additions & 13 deletions src/duckdb/src/execution/operator/scan/physical_table_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ class TableScanGlobalSourceState : public GlobalSourceState {
if (op.dynamic_filters && op.dynamic_filters->HasFilters()) {
table_filters = op.dynamic_filters->GetFinalTableFilters(op, op.table_filters.get());
}

if (op.function.init_global) {
TableFunctionInitInput input(op.bind_data.get(), op.column_ids, op.projection_ids, GetTableFilters(op),
auto filters = table_filters ? *table_filters : GetTableFilters(op);
TableFunctionInitInput input(op.bind_data.get(), op.column_ids, op.projection_ids, filters,
op.extra_info.sample_options);

global_state = op.function.init_global(context, input);
if (global_state) {
max_threads = global_state->MaxThreads();
Expand Down Expand Up @@ -92,23 +95,24 @@ unique_ptr<GlobalSourceState> PhysicalTableScan::GetGlobalSourceState(ClientCont
SourceResultType PhysicalTableScan::GetData(ExecutionContext &context, DataChunk &chunk,
OperatorSourceInput &input) const {
D_ASSERT(!column_ids.empty());
auto &gstate = input.global_state.Cast<TableScanGlobalSourceState>();
auto &state = input.local_state.Cast<TableScanLocalSourceState>();
auto &g_state = input.global_state.Cast<TableScanGlobalSourceState>();
auto &l_state = input.local_state.Cast<TableScanLocalSourceState>();

TableFunctionInput data(bind_data.get(), l_state.local_state.get(), g_state.global_state.get());

TableFunctionInput data(bind_data.get(), state.local_state.get(), gstate.global_state.get());
if (function.function) {
function.function(context.client, data, chunk);
} else {
if (gstate.in_out_final) {
function.in_out_function_final(context, data, chunk);
}
function.in_out_function(context, data, gstate.input_chunk, chunk);
if (chunk.size() == 0 && function.in_out_function_final) {
function.in_out_function_final(context, data, chunk);
gstate.in_out_final = true;
}
return chunk.size() == 0 ? SourceResultType::FINISHED : SourceResultType::HAVE_MORE_OUTPUT;
}

if (g_state.in_out_final) {
function.in_out_function_final(context, data, chunk);
}
function.in_out_function(context, data, g_state.input_chunk, chunk);
if (chunk.size() == 0 && function.in_out_function_final) {
function.in_out_function_final(context, data, chunk);
g_state.in_out_final = true;
}
return chunk.size() == 0 ? SourceResultType::FINISHED : SourceResultType::HAVE_MORE_OUTPUT;
}

Expand Down
Loading

0 comments on commit eeb938d

Please sign in to comment.