Skip to content

Commit

Permalink
Merge pull request #10054 from hawkfish/distinct-gcc
Browse files Browse the repository at this point in the history
Internal #940: GCC Window Distinct
  • Loading branch information
Mytherin committed Dec 22, 2023
2 parents a491470 + 47cfe1d commit 0ad4044
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/execution/window_segment_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,20 +1142,21 @@ void WindowDistinctAggregator::Finalize(const FrameStats &stats) {
// 6: prevIdcs ← []
// 7: prevIdcs[0] ← “-”
const auto count = inputs.size();
using ZippedTuple = DistinctSortTree::ZippedTuple;
DistinctSortTree::ZippedElements prev_idcs;
prev_idcs.resize(count);

// To handle FILTER clauses we make the missing elements
// point to themselves so they won't be counted.
if (in_size < count) {
for (idx_t i = 0; i < count; ++i) {
prev_idcs[i] = {i + 1, i};
prev_idcs[i] = ZippedTuple(i + 1, i);
}
}

auto *input_idx = FlatVector::GetData<idx_t>(scan_chunk.data[0]);
auto i = input_idx[scan_idx++];
prev_idcs[i] = {0, i};
prev_idcs[i] = ZippedTuple(0, i);

SBIterator curr(*global_sort, ExpressionType::COMPARE_LESSTHAN);
SBIterator prev(*global_sort, ExpressionType::COMPARE_LESSTHAN);
Expand Down Expand Up @@ -1187,9 +1188,9 @@ void WindowDistinctAggregator::Finalize(const FrameStats &stats) {
// 11: else
// 12: prevIdcs[i] ← “-”
if (!lt) {
prev_idcs[i] = {second + 1, i};
prev_idcs[i] = ZippedTuple(second + 1, i);
} else {
prev_idcs[i] = {0, i};
prev_idcs[i] = ZippedTuple(0, i);
}
}
// 13: return prevIdcs
Expand Down

0 comments on commit 0ad4044

Please sign in to comment.