v0.4.0
-
bigquery:
-NewGCSReferenceis now a function, not a method onClient.Table.LoaderFromnow accepts aReaderSource, enabling
loading data into a table from a file or anyio.Reader.
-
Client.Table and Client.OpenTable have been removed.
Replaceclient.OpenTable("project", "dataset", "table")
with
client.DatasetInProject("project", "dataset").Table("table")
-
Client.CreateTable has been removed.
Replaceclient.CreateTable(ctx, "project", "dataset", "table")
with
client.DatasetInProject("project", "dataset").Table("table").Create(ctx)
-
Dataset.ListTables have been replaced with Dataset.Tables.
Replacetables, err := ds.ListTables(ctx)
with
it := ds.Tables(ctx) for { table, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: use table. }
-
Client.Read has been replaced with Job.Read, Table.Read and Query.Read.
Replaceit, err := client.Read(ctx, job)
with
it, err := job.Read(ctx)
and similarly for reading from tables or queries.
-
The iterator returned from the Read methods is now named RowIterator. Its
behavior is closer to the other iterators in these libraries. It no longer
supports the Schema method; see the next item.
Replacefor it.Next(ctx) { var vals ValueList if err := it.Get(&vals); err != nil { // TODO: Handle error. } // TODO: use vals. } if err := it.Err(); err != nil { // TODO: Handle error. }
with
for { var vals ValueList err := it.Next(&vals) if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: use vals. }Instead of the
RecordsPerRequest(n)option, writeit.PageInfo().MaxSize = n
Instead of the
StartIndex(i)option, writeit.StartIndex = i
-
ValueLoader.Load now takes a Schema in addition to a slice of Values.
Replacefunc (vl *myValueLoader) Load(v []bigquery.Value)
with
func (vl *myValueLoader) Load(v []bigquery.Value, s bigquery.Schema)
-
Table.Patch is replace by Table.Update.
Replacep := table.Patch() p.Description("new description") metadata, err := p.Apply(ctx)
with
metadata, err := table.Update(ctx, bigquery.TableMetadataToUpdate{ Description: "new description", })
-
Client.Copy is replaced by separate methods for each of its four functions.
All options have been replaced by struct fields.-
To load data from Google Cloud Storage into a table, use Table.LoaderFrom.
Replace
client.Copy(ctx, table, gcsRef)
with
table.LoaderFrom(gcsRef).Run(ctx)
Instead of passing options to Copy, set fields on the Loader:
loader := table.LoaderFrom(gcsRef) loader.WriteDisposition = bigquery.WriteTruncate
-
To extract data from a table into Google Cloud Storage, use
Table.ExtractorTo. Set fields on the returned Extractor instead of
passing options.Replace
client.Copy(ctx, gcsRef, table)
with
table.ExtractorTo(gcsRef).Run(ctx)
-
To copy data into a table from one or more other tables, use
Table.CopierFrom. Set fields on the returned Copier instead of passing options.Replace
client.Copy(ctx, dstTable, srcTable)
with
dst.Table.CopierFrom(srcTable).Run(ctx)
-
To start a query job, create a Query and call its Run method. Set fields
on the query instead of passing options.Replace
client.Copy(ctx, table, query)
with
query.Run(ctx)
-
-
Table.NewUploader has been renamed to Table.Uploader. Instead of options,
configure an Uploader by setting its fields.
Replaceu := table.NewUploader(bigquery.UploadIgnoreUnknownValues())
with
u := table.NewUploader(bigquery.UploadIgnoreUnknownValues()) u.IgnoreUnknownValues = true
-
pubsub: remove
pubsub.Done. Useiterator.Doneinstead, whereiteratoris the package
google.golang.org/api/iterator.