Commit 3bee970
authored
Migrate case conversion and substr_index to fallible string view builder APIs (#23074)
## Which issue does this PR close?
* Part of #22688
## Rationale for this change
This PR continues the migration to fallible string builder APIs for
string UDFs that previously relied on infallible `append_value` and
`append_placeholder` calls.
The non-ASCII case conversion paths in `string/common.rs` and the
generic implementations in `unicode/substrindex.rs` could panic when
string view metadata exceeds ByteView's `i32::MAX` limits. Converting
these call sites to use fallible builder APIs allows overflow conditions
to be propagated as `DataFusionError`s instead of causing panics.
This work is part of the broader effort in #22688 to eliminate
panic-based overflow handling in string builders.
## What changes are included in this PR?
* Migrated non-ASCII case conversion paths in `string/common.rs` to use:
* `try_append_value`
* `try_append_placeholder`
* Migrated `substr_index_general` and `map_strings` in
`unicode/substrindex.rs` to use:
* `try_append_value`
* `try_append_placeholder`
* Added fallible APIs to `StringViewArrayBuilder`:
* `try_append_value`
* `try_append_placeholder`
* `try_ensure_long_capacity`
* Added overflow error generation for StringView-specific limits:
* `string_view_overflow_error`
* Refactored StringView view construction to validate:
* value length
* buffer offsets
* completed buffer count
* Preserved existing infallible APIs (`append_value`,
`append_placeholder`, `ensure_long_capacity`) as wrappers around the
fallible implementations, maintaining existing behavior for callers that
still use them.
## Are these changes tested?
Yes.
Added the following unit tests:
* `string_view_builder_try_append_success_path`
* `test_substr_index_all_nulls`
These tests verify:
* Successful operation of the new fallible StringView builder APIs.
* Correct null propagation behavior in `substr_index_general`.
Existing case conversion and `substr_index` tests continue to validate
the normal execution paths. No dedicated overflow-triggering tests were
added in this PR.
## Are there any user-facing changes?
No user-facing functionality changes are expected.
The primary behavioral change is that certain internal string-builder
overflow conditions can now be returned as `DataFusionError`s rather
than triggering panics, improving robustness in extreme cases.
## LLM-generated code disclosure
This PR includes LLM-generated code and comments. All LLM-generated
content has been manually reviewed.1 parent 284ae30 commit 3bee970
3 files changed
Lines changed: 136 additions & 43 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
384 | | - | |
| 384 | + | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
| 438 | + | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
| 445 | + | |
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
342 | 346 | | |
343 | 347 | | |
344 | 348 | | |
| |||
684 | 688 | | |
685 | 689 | | |
686 | 690 | | |
687 | | - | |
| 691 | + | |
688 | 692 | | |
689 | | - | |
| 693 | + | |
690 | 694 | | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
696 | 700 | | |
697 | | - | |
| 701 | + | |
698 | 702 | | |
699 | | - | |
700 | | - | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
701 | 706 | | |
702 | 707 | | |
703 | | - | |
| 708 | + | |
704 | 709 | | |
705 | 710 | | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
| 711 | + | |
716 | 712 | | |
717 | 713 | | |
718 | | - | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
719 | 719 | | |
720 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
721 | 754 | | |
722 | 755 | | |
723 | 756 | | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
724 | 760 | | |
725 | 761 | | |
726 | 762 | | |
727 | 763 | | |
728 | 764 | | |
729 | 765 | | |
730 | 766 | | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
| 767 | + | |
735 | 768 | | |
736 | | - | |
737 | | - | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
738 | 775 | | |
739 | 776 | | |
740 | 777 | | |
| |||
744 | 781 | | |
745 | 782 | | |
746 | 783 | | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
747 | 795 | | |
748 | 796 | | |
749 | 797 | | |
| |||
754 | 802 | | |
755 | 803 | | |
756 | 804 | | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
761 | 811 | | |
762 | 812 | | |
763 | 813 | | |
| |||
768 | 818 | | |
769 | 819 | | |
770 | 820 | | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
771 | 829 | | |
772 | 830 | | |
773 | 831 | | |
| |||
1601 | 1659 | | |
1602 | 1660 | | |
1603 | 1661 | | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
1604 | 1676 | | |
1605 | 1677 | | |
1606 | 1678 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| |||
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
490 | | - | |
| 490 | + | |
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
| 496 | + | |
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
| |||
797 | 797 | | |
798 | 798 | | |
799 | 799 | | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
800 | 821 | | |
801 | 822 | | |
802 | 823 | | |
| |||
0 commit comments