protobuf-bigquery-go icon indicating copy to clipboard operation
protobuf-bigquery-go copied to clipboard

OneOf fields skipped as "synthetic" but still marshalled by the Marshaller

Open ubunatic opened this issue 1 year ago • 1 comments

We have upgraded from v0.25.0 to a higher version lately and see issues with newly created tables. We use options.InferSchema(msg) to create and update schemas for our tables. We use options.Marshal(msg) to marshal the messages.

With version v.26.0+, some rows cannot be ingested and BQ rejects them with an error:

some.field._some_one_of: no such field: _some_one_of."; Reason: "invalid"

We use these Options:

protobq.SchemaOptions{
	UseEnumNumbers:           false,
	UseOneofFields:           true,
	UseDateTimeWithoutOffset: true,
}

When calling options.Marshal(msg), the nested map[string]bigquery.Value will contain the _some_one_of field. When calling options.InferSchema(msg) the nested bigquery.Schema will not contain the _some_one_of field anymore.

When I disable this change:

  // if oneof.IsSynthetic() {
  // 	continue
  // }

everything works as expected.

How do you handle this case?

ubunatic avatar Jan 11 '24 16:01 ubunatic

I added a PR: #369 to fix it. Let me know if this works for you. Starting next week, we will vendor our branch with the fix to fill our DWH. 🤞🏼 I will post the results here too.

ubunatic avatar Jan 12 '24 22:01 ubunatic