Skip to content

fix(types): normalize nullable any return bindings - #291

Open
dd-david-levin wants to merge 1 commit into
substrait-io:mainfrom
dd-david-levin:map-nested-any-nullability
Open

fix(types): normalize nullable any return bindings#291
dd-david-levin wants to merge 1 commit into
substrait-io:mainfrom
dd-david-levin:map-nested-any-nullability

Conversation

@dd-david-levin

Copy link
Copy Markdown

Summary

Normalize a nullable anyN? occurrence to the required base binding when deriving polymorphic return types, then let the return occurrence reapply its declared nullability.

This implements the return-substitution side of the semantics documented in substrait-io/substrait#960. In particular:

list<string?> against list<any1?> binds any1 = string
list<i64?> against list<any2?> binds any2 = i64
map<any1, any2?> resolves to map<string, i64?>

Without this change, the map key incorrectly remains nullable and resolves as map<string?, i64?>.

Details

  • Normalize nullable anyN? source occurrences in unwrapAnyTypeWithName.
  • Preserve the return occurrence's declaration, so anyN remains required and anyN? is nullable.
  • Add direct required/nullable substitution tests and a composite map regression test.
  • Make IntervalDayType.WithNullability honor the Type interface's copy contract. This prevents return derivation from mutating an input argument while normalizing its binding.

This is complementary to draft #244. That PR addresses broader argument matching and constrained-binding consistency; this PR is narrowly about extracting the correct binding for return-type substitution.

Testing

go test ./...
git diff --check

Both pass.


This PR was developed with AI assistance. All changes have been reviewed, and I take full responsibility for this contribution.

Treat a nullable anyN? occurrence as a nullable use of the required base binding when deriving composite return types. This lets list<any1?> resolve to required any1 while allowing the return occurrence to reapply nullable output.

Also make IntervalDayType.WithNullability honor the Type copy contract so return derivation cannot mutate function argument types.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.45%. Comparing base (985d911) to head (bfc7b50).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #291      +/-   ##
==========================================
+ Coverage   70.41%   70.45%   +0.03%     
==========================================
  Files          48       48              
  Lines       11087    11090       +3     
==========================================
+ Hits         7807     7813       +6     
+ Misses       2910     2908       -2     
+ Partials      370      369       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dd-david-levin
dd-david-levin marked this pull request as draft August 13, 2026 14:16
@dd-david-levin
dd-david-levin marked this pull request as ready for review August 13, 2026 14:50
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.

2 participants