mohamedawnallah commented on code in PR #33988:
URL: https://github.com/apache/beam/pull/33988#discussion_r1965906623


##########
sdks/go/pkg/beam/io/bigqueryio/bigquery.go:
##########
@@ -190,13 +191,35 @@ func mustInferSchema(t reflect.Type) bigquery.Schema {
        if t.Kind() != reflect.Struct {
                panic(fmt.Sprintf("schema type must be struct: %v", t))
        }
+
+       registerTypeIfNeeded(t)
+
        schema, err := bigquery.InferSchema(reflect.Zero(t).Interface())
        if err != nil {
                panic(errors.Wrapf(err, "invalid schema type: %v", t))
        }
        return schema
 }
 
+func registerTypeIfNeeded(t reflect.Type) {
+       t = reflectx.SkipPtr(t)
+       key, ok := runtime.TypeKey(t)
+       if !ok {
+               panic(fmt.Sprintf("type %v must be a named type (not anonymous) 
for registration", t))
+       }
+
+       // Check if Beam has already been initialized.
+       if beam.Initialized() {

Review Comment:
   Thanks! I’ve updated it. Sorry for misinterpreting the previous feedback—I'm 
still wrapping my head around registering types before and after `beam.Init()`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to