Repository navigation
Commit 68a1b3e
fix: return NULL from
`BitXorAccumulator` kept a single `Option<T::Native>` whose `None` doubled as
"has not seen a non-NULL value yet". `retract_batch` could undo the value,
since XOR is its own inverse, but never moved the state back to `None`, so
once every non-NULL value had left a sliding window frame the accumulator
reported `Some(0)` and the query returned 0 where SQL semantics — and
`bit_xor`'s own documented "all non-null input values" contract — require
NULL. The same aggregate over a whole partition returned NULL correctly,
because that path never retracts.
Track the number of non-NULL values currently accumulated and return NULL
when it is zero, the same way `avg` does. `retract_batch` no longer delegates
to `update_batch`, since the count has to move the other way. A genuine zero,
such as `bit_xor` of [5, 5], is still returned as 0.
`state_fields` is unchanged: the count never has to be serialized, because
`state()` already yields NULL when there is no non-NULL input and
`merge_batch` adds nothing for a NULL state. `bit_and`, `bit_or` and
`bit_xor(DISTINCT ..)` do not implement `retract_batch` and are unaffected.
Closes apache#26470
Co-Authored-By: Claude Opus 5 <[email protected]>bit_xor when a sliding frame has no non-NULL values1 parent 862843f commit 68a1b3e
2 files changed
Lines changed: 119 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
437 | 439 | | |
438 | 440 | | |
439 | 441 | | |
| |||
444 | 446 | | |
445 | 447 | | |
446 | 448 | | |
447 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
448 | 453 | | |
449 | 454 | | |
450 | 455 | | |
| |||
457 | 462 | | |
458 | 463 | | |
459 | 464 | | |
| 465 | + | |
460 | 466 | | |
461 | 467 | | |
462 | 468 | | |
463 | 469 | | |
464 | | - | |
465 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
466 | 478 | | |
467 | 479 | | |
468 | 480 | | |
469 | 481 | | |
470 | 482 | | |
471 | 483 | | |
472 | 484 | | |
473 | | - | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
474 | 492 | | |
475 | 493 | | |
476 | 494 | | |
| |||
580 | 598 | | |
581 | 599 | | |
582 | 600 | | |
583 | | - | |
| 601 | + | |
584 | 602 | | |
585 | 603 | | |
586 | 604 | | |
| |||
603 | 621 | | |
604 | 622 | | |
605 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
606 | 671 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6736 | 6736 | | |
6737 | 6737 | | |
6738 | 6738 | | |
| 6739 | + | |
| 6740 | + | |
| 6741 | + | |
| 6742 | + | |
| 6743 | + | |
| 6744 | + | |
| 6745 | + | |
| 6746 | + | |
| 6747 | + | |
| 6748 | + | |
| 6749 | + | |
| 6750 | + | |
| 6751 | + | |
| 6752 | + | |
| 6753 | + | |
| 6754 | + | |
| 6755 | + | |
| 6756 | + | |
| 6757 | + | |
| 6758 | + | |
| 6759 | + | |
| 6760 | + | |
| 6761 | + | |
| 6762 | + | |
| 6763 | + | |
| 6764 | + | |
| 6765 | + | |
| 6766 | + | |
| 6767 | + | |
| 6768 | + | |
| 6769 | + | |
| 6770 | + | |
| 6771 | + | |
| 6772 | + | |
| 6773 | + | |
| 6774 | + | |
| 6775 | + | |
| 6776 | + | |
| 6777 | + | |
| 6778 | + | |
| 6779 | + | |
| 6780 | + | |
| 6781 | + | |
| 6782 | + | |
| 6783 | + | |
| 6784 | + | |
| 6785 | + | |
| 6786 | + | |
| 6787 | + | |
6739 | 6788 | | |
6740 | 6789 | | |
6741 | 6790 | | |
| |||
0 commit comments