code: def update_schema(schema_old, schema_new):
      
      old_fields = schema_old["fields"]
      new_fields = schema_new["fields"]
      output_fields = list(old_fields)
  
      field_indices = {field["name"]: i for i, field in enumerate(output_fields)}
  
      for field in new_fields:
          name = field["name"]
          if name in field_indices:
              # replace old field with new field of same name
              output_fields[field_indices[name]] = field
          else:
              # add new field
              output_fields.append(field)
  
      return {"fields": output_fields}
docs: Given an old BigQuery schema, update it with a new one.
  
      Where a field name is the same, the new will replace the old. Any
      new fields not present in the old schema will be added.
  
      Arguments:
          schema_old: the old schema to update
          schema_new: the new schema which will overwrite/extend the old