// updateTableSchema updates a pre-existing table's schema func (b *Streamer) updateTableSchema(projectID, datasetID, tableID string, schema *bigquery.TableSchema) (*bigquery.Table, error) { tables := bigquery.NewTablesService(b.service) table := &bigquery.Table{ Schema: schema, TableReference: &bigquery.TableReference{ ProjectId: projectID, DatasetId: datasetID, TableId: tableID, }, } return tables.Update(projectID, datasetID, tableID, table).Do() }
func (ts *tableStreamer) createTable(schema *bigquery.TableSchema) error { tablesService := bigquery.NewTablesService(ts.streamer.service) table := &bigquery.Table{ Schema: schema, TableReference: &bigquery.TableReference{ ProjectId: ts.streamer.project, DatasetId: ts.streamer.dataset, TableId: ts.table, }, } _, err := tablesService.Insert(ts.streamer.project, ts.streamer.dataset, table).Do() if err == nil || isAlreadyExistsErr(err) { return nil } return err }