'Takes a cursor, and writes the BigQuery schema for the results to a
local file system.
:return: A dictionary where key is a filename to be used as an object
name in GCS, and values are file handles to local files that
contains the BigQuery schema fields in .json format.'

def _write_local_schema_file(self, cursor):

    schema = []
    for field in cursor.description:
        field_name = field[0]
        field_type = self.type_map(field[1])
        field_mode = ('NULLABLE' if (field[6] or (field_type == 'TIMESTAMP')) else 'REQUIRED')
        schema.append({'name': field_name, 'type': field_type, 'mode': field_mode})
    logging.info('Using    schema    for    %s:    %s', self.schema_filename, schema)
    tmp_schema_file_handle = NamedTemporaryFile(delete=True)
    json.dump(schema, tmp_schema_file_handle)
    return {self.schema_filename: tmp_schema_file_handle}
