Repository navigation
Commit eb7a878
Let a required ANY argument be declared nullable, so it can validate itself
A function with a required `AnyArrow` argument had no way to produce a
good error when a caller omitted it. The framework parses arguments
before `on_bind()` runs, so the omission surfaced as
KeyError: "Argument 'questions': not found"
instead of the message the function had written for exactly that case,
which names the argument and shows its shape. Two things blocked the
obvious fix of `default=None`:
1. parameter_default_values_from_specs rejected ANY default on an
ANY-typed parameter. Only a VALUE default is unrepresentable there:
`None` is fine, because a null-typed array holds nulls and it is
column PRESENCE, not the value, that marks a parameter as having a
default — as that function's own docstring says. Narrowed the guard to
non-None defaults.
2. The marker types (AnyArrow, AnyArrowValue, TableInput) are recognised
by identity, so `AnyArrow | None` hid the marker: the parameter
silently became NULL-typed, and DuckDB could then cast nothing into
it — `Unimplemented type for cast (STRUCT(...) -> NULL)` at the first
real call. Both detection sites now unwrap an optional union first,
mirroring what `_accepts_none` already looks for.
Together these let a function declare
Annotated[AnyArrow | None, Arg("questions", default=None)]
for an argument that is required in practice but validated by the
function itself. Verified end to end against a real DuckDB ATTACH: the
missing case now raises the function's own message, and the struct, JSON
string and correlated LATERAL call shapes all still work with the
argument present.
Tests: an optional ANY argument keeps its ANY marker and null arrow type;
a None default on an ANY parameter builds a one-row null column; a
non-null default on one is still rejected.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 39ad674 commit eb7a878
2 files changed
Lines changed: 101 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
856 | 857 | | |
857 | 858 | | |
858 | 859 | | |
859 | | - | |
| 860 | + | |
860 | 861 | | |
861 | 862 | | |
862 | 863 | | |
| |||
865 | 866 | | |
866 | 867 | | |
867 | 868 | | |
868 | | - | |
| 869 | + | |
869 | 870 | | |
870 | 871 | | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
871 | 928 | | |
872 | 929 | | |
873 | 930 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
395 | 396 | | |
396 | 397 | | |
397 | 398 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | 399 | | |
404 | 400 | | |
405 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
406 | 415 | | |
407 | 416 | | |
408 | 417 | | |
| |||
538 | 547 | | |
539 | 548 | | |
540 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
541 | 574 | | |
542 | 575 | | |
543 | 576 | | |
| |||
744 | 777 | | |
745 | 778 | | |
746 | 779 | | |
| 780 | + | |
747 | 781 | | |
748 | 782 | | |
749 | 783 | | |
| |||
790 | 824 | | |
791 | 825 | | |
792 | 826 | | |
793 | | - | |
794 | | - | |
| 827 | + | |
| 828 | + | |
795 | 829 | | |
796 | 830 | | |
797 | 831 | | |
| |||
0 commit comments