Skip to content

fix(testcases/parser): implement VisitUserDefined so null::u!<type> parses#238

Open
SAY-5 wants to merge 2 commits intosubstrait-io:mainfrom
SAY-5:fix/testcases-parser-user-defined-null-237
Open

fix(testcases/parser): implement VisitUserDefined so null::u!<type> parses#238
SAY-5 wants to merge 2 commits intosubstrait-io:mainfrom
SAY-5:fix/testcases-parser-user-defined-null-237

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 23, 2026

Fixes #237.

TestCaseVisitor had no VisitUserDefined method, so dispatch fell through to BaseFuncTestCaseParserVisitor.VisitUserDefined which returns VisitChildren — nil for a terminal user-defined scalar. VisitNullArg then tried to use that nil as a types.Type and panicked with interface conversion: interface {} is nil, not string on inputs like null::u!geometry?.

Add a VisitUserDefined that returns a *types.UserDefinedType with the correct nullability (read from the optional trailing ?), so VisitNullArg gets a real type and produces a NullLiteral.

go test ./testcases/parser/... passes locally.

…arses

TestCaseVisitor had no VisitUserDefined method, so dispatch fell
through to BaseFuncTestCaseParserVisitor.VisitUserDefined which
returns VisitChildren — nil for a terminal user-defined scalar.
VisitNullArg then tried to use that nil as a types.Type and
panicked with 'interface conversion: interface {} is nil, not
string' on inputs like null::u!geometry?.

Add a VisitUserDefined that returns a *types.UserDefinedType with
the correct nullability (read from the optional trailing ?), so
VisitNullArg gets a real type and produces a NullLiteral.

Refs substrait-io/substrait-go issue 237.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 23, 2026

CLA assistant check
All committers have signed the CLA.

@benbellick
Copy link
Copy Markdown
Member

Nice, and welcome! Would you mind adding a test to show that it fixes the problem? Thanks!

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.84%. Comparing base (5073366) to head (b90e2a3).

Files with missing lines Patch % Lines
testcases/parser/visitor.go 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #238   +/-   ##
=======================================
  Coverage   68.84%   68.84%           
=======================================
  Files          47       47           
  Lines       10862    10872   +10     
=======================================
+ Hits         7478     7485    +7     
- Misses       3030     3032    +2     
- Partials      354      355    +1     

☔ View full report in Codecov by Sentry.
📢 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.

…it-io#237)

Per @benbellick's review on substrait-io#238: add a regression test confirming
the `VisitUserDefined` fix from this PR also fixes the panic the
issue reported.

`TestParseUserDefinedNullArg` runs the `null::u!geometry` and
`null::u!geometry?` forms through `ParseTestCasesFromString` and
asserts:

  - the parse does not panic / error (pre-fix it returned
    `Tree Visit panic error interface conversion: interface {} is
    nil, not string`)
  - the argument's `Type` is a `*types.UserDefinedType` rather than
    nil (which is what fell through to `VisitNullArg`'s `.(types.Type)`
    cast pre-fix)
  - the argument's `Value` is a `*expr.NullLiteral` whose `GetType()`
    is also a `*types.UserDefinedType` — the literal carries the
    parsed user-defined type forward correctly.

`VisitNullArg` always sets `CaseLiteral.Type`'s nullability to
`Nullable` regardless of the parsed `?`, so the test doesn't assert
on the wrapper nullability — it pins the type-shape contract that
the bug broke.

`go test ./testcases/parser/` is green (full suite passes too).

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented Apr 29, 2026

Thanks @benbellick! Added TestParseUserDefinedNullArg in latest commit covering both null::u!geometry and null::u!geometry?. Each case asserts the parse doesn't panic, the argument's Type is *types.UserDefinedType, and the value is a NullLiteral carrying that user-defined type forward. go test ./testcases/parser/ is green; full module test suite is green too.

@benbellick benbellick self-requested a review April 29, 2026 21:15
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.

Parser panics on null::U!<type> (user-defined type null literals)

3 participants