Skip to content

Commit

Permalink
Internal duckdb#215: QUANTILE Exclude Tests
Browse files Browse the repository at this point in the history
Back out range restriction.
Add median tests.
  • Loading branch information
Richard Wesley committed Sep 17, 2023
1 parent 596680d commit 65082ee
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 48 deletions.
8 changes: 4 additions & 4 deletions src/core_functions/aggregate/holistic/quantile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ void ReuseIndexes(idx_t *index, const FrameBounds *currs, const FrameBounds *pre
// Insert new indices
if (j > 0) {
// Subframe indices
const auto currs_start = currs[0].start;
const auto currs_end = currs[nframes - 1].end;
const FrameBounds last(currs_end, currs_end);
const auto union_start = MinValue(currs[0].start, prevs[0].start);
const auto union_end = MaxValue(currs[nframes - 1].end, prevs[nframes - 1].end);
const FrameBounds last(union_end, union_end);

idx_t p = 0;
idx_t c = 0;
for (auto idx = currs_start; idx < currs_end;) {
for (auto idx = union_start; idx < union_end;) {
int overlap = 0;

// Are we in the previous frame?
Expand Down
95 changes: 51 additions & 44 deletions test/sql/window/test_window_exclude.test
Original file line number Diff line number Diff line change
Expand Up @@ -651,50 +651,57 @@ ORDER BY i;
5 4
5 5

## MEDIAN and CURRENT ROW
#query II
#SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW) FROM generate_series(1,10) AS _(i) ORDER BY i;
#----
#1 2.5
#2 3.0
#3 4.0
#4 5.0
#5 6.0
#6 7.0
#7 8.0
#8 9.0
#9 9.0
#10 9.0
#
## MEDIAN and GROUP
#query II
#SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE GROUP) FROM generate_series(1,5) AS _(i), generate_series(1,2) ORDER BY i;
#----
#1 2.0
#1 2.0
#2 2.0
#2 3.0
#3 3.0
#3 4.0
#4 4.0
#4 5.0
#5 4.0
#5 NULL
#
## MEDIAN and TIES
#query II
#SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE TIES) FROM generate_series(1,5) AS _(i), generate_series(1,2) ORDER BY i;
#----
#1
#1 2.0
#2 2.0
#2 3.0
#3 3.0
#3 4.0
#4 4.0
#4 5.0
#5 5.0
#5 5.0
# MEDIAN and CURRENT ROW
query II
SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW)
FROM generate_series(1,10) AS _(i) ORDER BY i;
----
1 2.5
2 3.0
3 4.0
4 5.0
5 6.0
6 7.0
7 8.0
8 9.0
9 9.0
10 9.0

# MEDIAN and GROUP
query II
SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE GROUP)
FROM generate_series(1,5) AS _(i),
generate_series(1,2)
ORDER BY i;
----
1 2.0
1 2.0
2 2.0
2 3.0
3 3.0
3 4.0
4 4.0
4 5.0
5 4.0
5 NULL

# MEDIAN and TIES
query II
SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE TIES)
FROM generate_series(1,5) AS _(i),
generate_series(1,2)
ORDER BY i;
----
1 1.5
1 2.0
2 2.0
2 3.0
3 3.0
3 4.0
4 4.0
4 5.0
5 4.5
5 5.0



Expand Down

0 comments on commit 65082ee

Please sign in to comment.