Repository navigation
Commit e19fc94
fix: correct percentile_cont(DISTINCT) accumulation and sliding-window retract (apache#23913)
## Which issue does this PR close?
- Closes apache#23912.
## Rationale for this change
`DistinctPercentileContAccumulator` reused the shared set-based
`GenericDistinctBuffer`, which doesn't fit it: (1) the buffer asserts a
single input column but `percentile_cont` passes two (value +
percentile), so every `percentile_cont(DISTINCT ...)` panicked; (2) the
buffer is a plain `HashSet` with no multiplicity, so sliding-window
`retract_batch` dropped a value while duplicates were still in the
frame.
## What changes are included in this PR?
- Replace the shared buffer in this accumulator with a per-accumulator
`HashMap<Hashable, usize>` count map: `update_batch` reads only the
value column and increments; `retract_batch` decrements and removes a
key only at zero; `state`/`merge_batch` keep the same List state shape.
Other `GenericDistinctBuffer` users are untouched.
- Regression tests in `aggregate.slt` for the plain distinct query and
the sliding-window duplicate-retract case.
## Are these changes tested?
Yes — new regression tests; the full `aggregate.slt` suite passes.
## Are there any user-facing changes?
`percentile_cont(DISTINCT ...)` now works instead of panicking, and
returns correct results in sliding windows.1 parent 6504756 commit e19fc94
2 files changed
Lines changed: 75 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
665 | 672 | | |
666 | 673 | | |
667 | | - | |
| 674 | + | |
| 675 | + | |
668 | 676 | | |
669 | 677 | | |
670 | 678 | | |
671 | 679 | | |
672 | 680 | | |
673 | 681 | | |
674 | | - | |
| 682 | + | |
675 | 683 | | |
676 | 684 | | |
677 | 685 | | |
| |||
684 | 692 | | |
685 | 693 | | |
686 | 694 | | |
687 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
688 | 706 | | |
689 | 707 | | |
690 | 708 | | |
691 | | - | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
692 | 716 | | |
693 | 717 | | |
694 | 718 | | |
695 | | - | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
696 | 727 | | |
697 | 728 | | |
698 | 729 | | |
699 | | - | |
700 | | - | |
| 730 | + | |
701 | 731 | | |
702 | 732 | | |
703 | 733 | | |
704 | 734 | | |
705 | 735 | | |
706 | | - | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
707 | 739 | | |
708 | 740 | | |
709 | 741 | | |
| |||
713 | 745 | | |
714 | 746 | | |
715 | 747 | | |
716 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
717 | 754 | | |
718 | 755 | | |
719 | 756 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1104 | 1104 | | |
1105 | 1105 | | |
1106 | 1106 | | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
1107 | 1134 | | |
1108 | 1135 | | |
1109 | 1136 | | |
| |||
0 commit comments