Skip to content

feat(core)!: derive container return types from nested argument bindings - #1289

Open
alexandrefimov wants to merge 2 commits into
substrait-io:mainfrom
alexandrefimov:issue-1241-container-return-types
Open

feat(core)!: derive container return types from nested argument bindings#1289
alexandrefimov wants to merge 2 commits into
substrait-io:mainfrom
alexandrefimov:issue-1241-container-return-types

Conversation

@alexandrefimov

@alexandrefimov alexandrefimov commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Parameterized list returns currently fail even when their element type is available from the arguments. For filter, sort and transform, type variables inside list and function arguments are also never bound.

Bind type and integer parameters recursively through list, map, struct and function arguments, and derive container returns from those bindings. Preserve nested nullability and enforce shared parameter, literal and variadic constraints from spec v0.102.0. If the available bindings leave a nested element's nullability undetermined, derivation fails.

The spec table does not cover a wildcard shared by a top-level argument and an unmarked list element. Keep existing calls such as index_in(i32, list<i32?>) valid: the top-level occurrence leaves the variable's nullability open, and the nested occurrence determines it. Two unmarked nested occurrences must still agree on nullability.

This enables the six Java-side variants in #1241: filter, sort, transform, string_split, regexp_string_split and regexp_match_substring_all. quantile remains unsupported because the pinned catalog uses an anonymous any in its return type. It needs the spec fix and a packaging update.

Closes #1241

BREAKING CHANGE: Function.resolveType now checks container argument shapes and shared parameter constraints even when the return type is concrete. Calls that previously derived a type despite invalid arguments can now fail. Pass Type.Func for function arguments and use types that satisfy the declared shapes and parameter constraints.

Parameterized list returns currently fail even when their element type is available from the arguments. For filter, sort and transform, type variables inside list and function arguments are also never bound.

Bind type and integer parameters recursively through list, map, struct and function arguments, and derive container returns from those bindings. Preserve nested nullability and enforce shared parameter, literal and variadic constraints from [spec v0.102.0](https://github.com/substrait-io/substrait/blob/v0.102.0/site/docs/expressions/scalar_functions.md#nullability-and-any-type-binding). If the available bindings leave a nested element's nullability undetermined, derivation fails.

This enables the six Java-side variants in substrait-io#1241: filter, sort, transform, string_split, regexp_string_split and regexp_match_substring_all. quantile remains unsupported because the pinned catalog uses an anonymous any in its return type. It needs [the spec fix](substrait-io/substrait#1193) and a packaging update.

Closes substrait-io#1241
Let nested wildcard occurrences determine the variable's nullability while
keeping nested-to-nested consistency checks. Cover index_in with nullable
list elements and argument-order independence.

Add a successful derived-output validation case and check that catalog
function arguments require Type.Func.
@alexandrefimov alexandrefimov changed the title feat(core): derive container return types from nested argument bindings feat(core)!: derive container return types from nested argument bindings Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: return-type derivation cannot evaluate a list return, and bind never recurses into container declarations

1 participant