Skip to content
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

[Bug][Go SDK] Native BigQuery IO should require registrations for passed in types. #26298

Open
1 of 15 tasks
lostluck opened this issue Apr 17, 2023 · 4 comments · May be fixed by #33988
Open
1 of 15 tasks

[Bug][Go SDK] Native BigQuery IO should require registrations for passed in types. #26298

lostluck opened this issue Apr 17, 2023 · 4 comments · May be fixed by #33988

Comments

@lostluck
Copy link
Contributor

What happened?

On distributed runners, the type must be registered to ensure it's serialized correctly. This can cause problems for BigQueryIO's "Null" type wrappers, which will lose their type identity going through beam serialization.

The user side solution is to register their type with beam.

func init() {
   beam.RegisterType(reflect.TypeOf((*BigQueryEntity)(nil)).Elem())
}

Or to use the register package on a downstream DoFn, which will register input and output types from the DoFn's ProcessElement method.

func init() {
   register.DoFn1x1[BigQueryEntity, Outut]((*myDoFn)(nil))
}

However it can be easy to forget to do this. So we can have the BigqueryIO do this at pipeline construction, to make the behavior clear and avoid user issues at pipeline execution time.

By adding to the internal mustInferSchema function, and have it get the key and look up the type with the beam runtime functions [runtime.TypeKey and runtime.LookupType. ](https://github.com/apache/beam/blob/sdks/v2.46.0/sdks/go/pkg/beam/core/runtime/types.go#L50

Note, that due to current limitations on looking up arbitrary types in Go, type registration must happen before beam.Init is called, so we can't simply register types there. We need to fail with a clear error message and instructions.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Samza Runner
  • Component: Twister2 Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner
@listux
Copy link

listux commented May 5, 2023

I would love to help and take this bug, please let me know if that's ok and I'll open a PR.

@listux
Copy link

listux commented May 6, 2023

.take-issue

@mohamedawnallah
Copy link
Contributor

It seems this issue has been inactive for a while, and no one has submitted a PR to address it. I'd like to take it on. 🙏

@mohamedawnallah
Copy link
Contributor

.take-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants