Skip to content

Improve function encapsulation API - #4397

Merged
hatyo merged 7 commits into
FoundationDB:mainfrom
hatyo:callsite-arguments
Jul 30, 2026
Merged

hatyo merged 7 commits into
FoundationDB:mainfrom
hatyo:callsite-arguments

Conversation

@hatyo

@hatyo hatyo commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

This reworks function encapsulation so that a function receives the call site it was invoked from, rather than just a bag of arguments. CatalogedFunction's two encapsulate overloads, one positional, one named, collapse into a single encapsulate(CallSiteArguments), where CallSiteArguments is a sealed type that knows which calling convention was used and carries the window specification and any call-site options alongside the arguments themselves. Functions that only ever supported one convention no longer have to implement a second method just to throw from it, and UserDefinedMacroFunction, the one implementor that genuinely handles both, now branches on isNamed() in a single place.

Options are the substantive part of the change. A function declares the options it understands through getSupportedOptions(), using typed Option keys held as constants next to the function, and BuiltInFunction.encapsulate funnels every built-in through validateAndNormalizeOptions so an option the function doesn't declare is rejected with a proper error instead of being silently dropped, and a recognized one arrives already converted to its declared type. Options are deliberately not a global namespace: they're resolved only against the declared set of the function actually being called, so two unrelated functions may reuse a name without colliding. With the window specification and options both first-class, row_number no longer needs the partition and ordering columns smuggled in as two synthetic array constructors, and RowNumberFn reads ef_search and return_vectors directly from the call site.

That in turn lets the higher-order machinery go away. RowNumberHighOrderValue was only ever a carrier for the curried configuration, so it and the arity-retry fallback in SemanticAnalyzer are both removed, and PValue field 58 is reserved.

This fixes #4406.

@normen662 normen662 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I am okay with the general approach being taken. A bunch of little things, but I think you said this is not ready yet anyway?

@hatyo hatyo added the enhancement New feature or request label Jul 28, 2026
@hatyo
hatyo marked this pull request as ready for review July 28, 2026 17:03
@hatyo
hatyo merged commit daaf0f2 into FoundationDB:main Jul 30, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rework the function encapsulation API around an explicit call site

2 participants