-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add types.Unalias to types assertions and types switches to get an underlying type instead of types.Alias
#33868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…into go-type-unaliasing
…et an underlying type instead of types.Alias
…et an underlying type instead of types.Alias
…into go-type-unaliasing
|
Assigning reviewers. If you would like to opt out of this review, comment R: @lostluck for label go. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
lostluck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the other comments are the main concerns: We don't want to generate code with underlying/aliased types, we want to use the aliased types for naming things.
There's certainly value in the cases where an alias could be made instead of the raw code. The Unalias handling would have been great when this was originally written, and would have lead to a different approach, had it existed pre generics at all.
However, as I said in my other message: There isn't a great deal of value in fixing this code: users should be migrating to the generic register package, vs trying to use this belabored code generator.
lostluck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
|
Hi,
I've just sent a fix for this. But there is another problem too.
When I run tests I can see that `
github.com/apache/beam/sdks/v2/go/test/integration/io/mongodbio` fails with
"panic: checked path: $XDG_RUNTIME_DIR" and I'm not sure why.
…On Wed, Feb 19, 2025 at 3:26 PM Robert Burke ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In sdks/go/pkg/beam/util/starcgenx/starcgenx.go
<#33868 (comment)>:
> if t, ok := t.(*types.Named); ok {
- if pkg := t.Obj().Pkg(); pkg != nil {
+ e.Printf("extractType: adding import path %q for %v\n", pkg.Path(), t)
This should be inside the following if block. Pkg isn't defined yet .
—
Reply to this email directly, view it on GitHub
<#33868 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXKYBXAZJ36LXBHPBAMIY4D2QSIARAVCNFSM6AAAAABWRN622CVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMMRWHE4DQNBUGQ>
.
You are receiving this because you authored the thread.Message ID:
<apache/beam/pull/33868/review/2626988444 ***@***.***>
|
|
That seems like a flake or local misconfiguration. I wouldn't worry about it. Some of the tests aren't set up to run standalone with the go tool, but with the Gradle wrapper the repo uses. Just need to run go fmt on shimgenx.go and this will be done. |
|
Sorry i meant starcgenx.go. |
types.Unlias to types assertions and types switches to get an underlying type instead of types.Aliastypes.Unalias to types assertions and types switches to get an underlying type instead of types.Alias
|
fyi: I'll remove the log line that causes this error: "Error: util/starcgenx/starcgenx.go:521:67: types.Rhs requires go1.23 or later (file is go1.22)" |
|
#34039 fixes the missing edge case here where alias types might not get registered properly, leading to no code generated for them. |
…underlying type instead of types.Alias (apache#33868)
#34024) * #34009 avro generic record to beam row conversion added support for all logical types and conversions * using string comparison to avoid class not found issues with earlier versions of avro * using string comparison to avoid class not found issues with earlier versions of avro * com.github.davidmc24.gradle.plugin:gradle-avro-plugin:1.9.1 * using string comparison to avoid class not found issues with earlier versions of avro * com.github.davidmc24.gradle.plugin:gradle-avro-plugin:1.9.1 * Add `types.Unalias` to types assertions and types switches to get an underlying type instead of types.Alias (#33868) * Revert huggingface transformers to 4.30.0 (#34025) * add endpoint type to WorkerMetadataResponse proto (#33953) * add endpoint type to WorkerMetadataResponse proto * add default value to endpoint_type * add hashcode/equals to WaitTest helper classes to avoid log error (#34006) * Add enable_lineage experiment to Dataflow tests (#34027) * Add UUID support in SpannerSchema (#34034) * Add UUID support in Spanner Schema * Add test * fix dashboard link (#34023) * [Go SDK] Add missing type inspection case for Alias types. (#34039) * removed unneeded license header * remove unneeded license header * Added tests for specific records generated with avro 1.8.2 and 1.9.2, and to add custom conversions * Supporting different UUID representations in different avro versions * Spotless fixes * fix dependency typo --------- Co-authored-by: Alfredo Scaccialepre <alfredo.scaccialepre@edreamsodigeo.com> Co-authored-by: synenka <97878236+synenka@users.noreply.github.com> Co-authored-by: Vitaly Terentyev <vitaly.terentyev@akvelon.com> Co-authored-by: martin trieu <martinkt@google.com> Co-authored-by: scwhittle <scwhittle@users.noreply.github.com> Co-authored-by: Yi Hu <yathu@google.com> Co-authored-by: Luv Agarwal <luvagarwal.k@gmail.com> Co-authored-by: Ahmed Abualsaud <65791736+ahmedabu98@users.noreply.github.com> Co-authored-by: Robert Burke <lostluck@users.noreply.github.com>
… for a… (apache#34024) * apache#34009 avro generic record to beam row conversion added support for all logical types and conversions * using string comparison to avoid class not found issues with earlier versions of avro * using string comparison to avoid class not found issues with earlier versions of avro * com.github.davidmc24.gradle.plugin:gradle-avro-plugin:1.9.1 * using string comparison to avoid class not found issues with earlier versions of avro * com.github.davidmc24.gradle.plugin:gradle-avro-plugin:1.9.1 * Add `types.Unalias` to types assertions and types switches to get an underlying type instead of types.Alias (apache#33868) * Revert huggingface transformers to 4.30.0 (apache#34025) * add endpoint type to WorkerMetadataResponse proto (apache#33953) * add endpoint type to WorkerMetadataResponse proto * add default value to endpoint_type * add hashcode/equals to WaitTest helper classes to avoid log error (apache#34006) * Add enable_lineage experiment to Dataflow tests (apache#34027) * Add UUID support in SpannerSchema (apache#34034) * Add UUID support in Spanner Schema * Add test * fix dashboard link (apache#34023) * [Go SDK] Add missing type inspection case for Alias types. (apache#34039) * removed unneeded license header * remove unneeded license header * Added tests for specific records generated with avro 1.8.2 and 1.9.2, and to add custom conversions * Supporting different UUID representations in different avro versions * Spotless fixes * fix dependency typo --------- Co-authored-by: Alfredo Scaccialepre <alfredo.scaccialepre@edreamsodigeo.com> Co-authored-by: synenka <97878236+synenka@users.noreply.github.com> Co-authored-by: Vitaly Terentyev <vitaly.terentyev@akvelon.com> Co-authored-by: martin trieu <martinkt@google.com> Co-authored-by: scwhittle <scwhittle@users.noreply.github.com> Co-authored-by: Yi Hu <yathu@google.com> Co-authored-by: Luv Agarwal <luvagarwal.k@gmail.com> Co-authored-by: Ahmed Abualsaud <65791736+ahmedabu98@users.noreply.github.com> Co-authored-by: Robert Burke <lostluck@users.noreply.github.com>
Go 1.24's types package changes type representation: types created as aliases would be represented by
types.Aliasinstead of its underlying type as before. This requires updates to any code using go/types. Specifically, types.Unalias(t) may be needed before type assertions/switches to handle aliases.Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.