I'm making a RESTful API in Go that writes rows in BigQuery. I'm using Google BigQuery package for Go.
In order to create the BigQuery scheme, I'm infering the schema from a struct as described in the example.
The problem is that, the resulting schema has all the non-repeated fields as "Required", so that, when I want to upload a struct with null values, the null values are uploaded as empy fields...
This is an example of my struct:
type Stats struct {
Name string `bigquery:"name"`
LastName int `bigquery:"last_name"`
PhoneNumber string `bigquery:"phone_number"`
}
This is an example of how the schema is created:
testSchema, err := bigquery.InferSchema(Stats{})
if err != nil {
// TODO: Handle error.
}
And, if I upload a struct with only one field set:
rows := []*Stats{
{Name: "testA"},
}
u := table.Uploader()
err2 := u.Put(ctx, rows)
The result is that, in BigQuery, the fields "last_name" and "phone_number" is an empty string "" instead of NULL