/* patchTable will add any fields in the provided type that happen to be missing from the originalTable */ func (self *BigQuery) patchTable(typ reflect.Type, tablesService *gbigquery.TablesService, originalTable *gbigquery.Table) (err error) { table, err := self.buildTable(typ) if err != nil { return } unionTable := self.unionTables(table, originalTable) if _, err = tablesService.Patch(self.projectId, self.datasetId, originalTable.TableReference.TableId, unionTable).Do(); err != nil { err = errors.Errorf("Error trying to patch %#v with\n%v\n%v", typ.Name(), utils.Prettify(unionTable), err) return } return }
/* createTable will create a table for the provided type inside BigQuery */ func (self *BigQuery) createTable(typ reflect.Type, tablesService *gbigquery.TablesService) (err error) { table, err := self.buildTable(typ) if err != nil { return } if _, err = tablesService.Insert(self.projectId, self.datasetId, table).Do(); err != nil { if gapiErr, ok := err.(*googleapi.Error); ok && gapiErr.Code == 409 { self.Infof("Unable to create table for %v, someone else already did it", typ) err = nil return } err = errors.Errorf("Unable to create %#v with\n%v\n%v", typ.Name(), utils.Prettify(table), err) return } return }