fix(testcases/parser): implement VisitUserDefined so null::u!<type> parses#238
Open
SAY-5 wants to merge 2 commits intosubstrait-io:mainfrom
Open
fix(testcases/parser): implement VisitUserDefined so null::u!<type> parses#238SAY-5 wants to merge 2 commits intosubstrait-io:mainfrom
SAY-5 wants to merge 2 commits intosubstrait-io:mainfrom
Conversation
…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>
Member
|
Nice, and welcome! Would you mind adding a test to show that it fixes the problem? Thanks! |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
…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>
Author
|
Thanks @benbellick! Added |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #237.
TestCaseVisitorhad noVisitUserDefinedmethod, so dispatch fell through toBaseFuncTestCaseParserVisitor.VisitUserDefinedwhich returnsVisitChildren— nil for a terminal user-defined scalar.VisitNullArgthen tried to use that nil as atypes.Typeand panicked withinterface conversion: interface {} is nil, not stringon inputs likenull::u!geometry?.Add a
VisitUserDefinedthat returns a*types.UserDefinedTypewith the correct nullability (read from the optional trailing?), soVisitNullArggets a real type and produces aNullLiteral.go test ./testcases/parser/...passes locally.