예제 #1
0
파일: bigquery.go 프로젝트: DaviWei/utils-1
/*
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
}
예제 #2
0
파일: bigquery.go 프로젝트: DaviWei/utils-1
/*
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
}