Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Hive Partition Load - Unable to set a field mode to REQUIRED during load from GCS

I am attempting to load externally partitioned data into a BigQuery table using Python. The BQ table in question has one REQUIRED field, which corresponds to the custom partition key schema in the GCS uri.

For example, my custom uri which I use as the `source_uri_prefix` looks like this:

 

 

gs://my_bucket/my_table/{dt:DATE}

 

 

And my table schema is like this:

 

 

[
  bigquery.SchemaField("field_a", "STRING"),
  bigquery.SchemaField("field_b", "STRING"),
  bigquery.SchemaField("dt", "DATE", mode="REQUIRED"),
]

 

 

 However, whenever I attempt to load I get this error:

Show More
ERROR - 400 Provided Schema does not match Table project:dataset.table$YYYYMMDD. Field dt has changed mode from REQUIRED to NULLABLE

Is there a way to set the custom keys (in this case `dt`) mode in the source_uri_prefix to REQUIRED? Or is it just a given that any custom key in the source_uri_prefix is REQUIRED b/c it is automatically added during the load?

1 2 372
2 REPLIES 2