vendor: Update vendoring for the exec client and server implementations
Signed-off-by: Jacek J. Łakis <jacek.lakis@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
d25b88583f
commit
bf51655a7b
2124 changed files with 809703 additions and 5 deletions
93
vendor/cloud.google.com/go/examples/bigquery/concat_table/main.go
generated
vendored
Normal file
93
vendor/cloud.google.com/go/examples/bigquery/concat_table/main.go
generated
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// concat_table is an example client of the bigquery client library.
|
||||
// It concatenates two BigQuery tables and writes the result to another table.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"cloud.google.com/go/bigquery"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
project = flag.String("project", "", "The ID of a Google Cloud Platform project")
|
||||
dataset = flag.String("dataset", "", "The ID of a BigQuery dataset")
|
||||
src1 = flag.String("src1", "", "The ID of the first BigQuery table to concatenate")
|
||||
src2 = flag.String("src2", "", "The ID of the second BigQuery table to concatenate")
|
||||
dest = flag.String("dest", "", "The ID of the BigQuery table to write the result to")
|
||||
pollint = flag.Duration("pollint", 10*time.Second, "Polling interval for checking job status")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
flagsOk := true
|
||||
for _, f := range []string{"project", "dataset", "src1", "src2", "dest"} {
|
||||
if flag.Lookup(f).Value.String() == "" {
|
||||
fmt.Fprintf(os.Stderr, "Flag --%s is required\n", f)
|
||||
flagsOk = false
|
||||
}
|
||||
}
|
||||
if !flagsOk {
|
||||
os.Exit(1)
|
||||
}
|
||||
if *src1 == *src2 || *src1 == *dest || *src2 == *dest {
|
||||
log.Fatalf("Different values must be supplied for each of --src1, --src2 and --dest")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
client, err := bigquery.NewClient(ctx, *project)
|
||||
if err != nil {
|
||||
log.Fatalf("Creating bigquery client: %v", err)
|
||||
}
|
||||
|
||||
s1 := client.Dataset(*dataset).Table(*src1)
|
||||
s2 := client.Dataset(*dataset).Table(*src2)
|
||||
d := client.Dataset(*dataset).Table(*dest)
|
||||
|
||||
// Concatenate data.
|
||||
copier := d.CopierFrom(s1, s2)
|
||||
copier.WriteDisposition = bigquery.WriteTruncate
|
||||
job, err := copier.Run(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("Concatenating: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Job for concatenation operation: %+v\n", job)
|
||||
fmt.Printf("Waiting for job to complete.\n")
|
||||
|
||||
for range time.Tick(*pollint) {
|
||||
status, err := job.Status(ctx)
|
||||
if err != nil {
|
||||
fmt.Printf("Failure determining status: %v", err)
|
||||
break
|
||||
}
|
||||
if !status.Done() {
|
||||
continue
|
||||
}
|
||||
if err := status.Err(); err == nil {
|
||||
fmt.Printf("Success\n")
|
||||
} else {
|
||||
fmt.Printf("Failure: %+v\n", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
95
vendor/cloud.google.com/go/examples/bigquery/load/main.go
generated
vendored
Normal file
95
vendor/cloud.google.com/go/examples/bigquery/load/main.go
generated
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// load is an example client of the bigquery client library.
|
||||
// It loads a file from Google Cloud Storage into a BigQuery table.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"cloud.google.com/go/bigquery"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
project = flag.String("project", "", "The ID of a Google Cloud Platform project")
|
||||
dataset = flag.String("dataset", "", "The ID of a BigQuery dataset")
|
||||
table = flag.String("table", "", "The ID of a BigQuery table to load data into")
|
||||
bucket = flag.String("bucket", "", "The name of a Google Cloud Storage bucket to load data from")
|
||||
object = flag.String("object", "", "The name of a Google Cloud Storage object to load data from. Must exist within the bucket specified by --bucket")
|
||||
skiprows = flag.Int64("skiprows", 0, "The number of rows of the source data to skip when loading")
|
||||
pollint = flag.Duration("pollint", 10*time.Second, "Polling interval for checking job status")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
flagsOk := true
|
||||
for _, f := range []string{"project", "dataset", "table", "bucket", "object"} {
|
||||
if flag.Lookup(f).Value.String() == "" {
|
||||
fmt.Fprintf(os.Stderr, "Flag --%s is required\n", f)
|
||||
flagsOk = false
|
||||
}
|
||||
}
|
||||
if !flagsOk {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
client, err := bigquery.NewClient(ctx, *project)
|
||||
if err != nil {
|
||||
log.Fatalf("Creating bigquery client: %v", err)
|
||||
}
|
||||
|
||||
table := client.Dataset(*dataset).Table(*table)
|
||||
|
||||
gcs := bigquery.NewGCSReference(fmt.Sprintf("gs://%s/%s", *bucket, *object))
|
||||
gcs.SkipLeadingRows = *skiprows
|
||||
gcs.MaxBadRecords = 1
|
||||
gcs.AllowQuotedNewlines = true
|
||||
|
||||
// Load data from Google Cloud Storage into a BigQuery table.
|
||||
loader := table.LoaderFrom(gcs)
|
||||
loader.WriteDisposition = bigquery.WriteTruncate
|
||||
job, err := loader.Run(ctx)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Loading data: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Job for data load operation: %+v\n", job)
|
||||
fmt.Printf("Waiting for job to complete.\n")
|
||||
|
||||
for range time.Tick(*pollint) {
|
||||
status, err := job.Status(ctx)
|
||||
if err != nil {
|
||||
fmt.Printf("Failure determining status: %v", err)
|
||||
break
|
||||
}
|
||||
if !status.Done() {
|
||||
continue
|
||||
}
|
||||
if err := status.Err(); err == nil {
|
||||
fmt.Printf("Success\n")
|
||||
} else {
|
||||
fmt.Printf("Failure: %+v\n", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
98
vendor/cloud.google.com/go/examples/bigquery/query/main.go
generated
vendored
Normal file
98
vendor/cloud.google.com/go/examples/bigquery/query/main.go
generated
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// query is an example client of the bigquery client library.
|
||||
// It submits a query and writes the result to a table.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"cloud.google.com/go/bigquery"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var (
|
||||
project = flag.String("project", "", "The ID of a Google Cloud Platform project")
|
||||
dataset = flag.String("dataset", "", "The ID of a BigQuery dataset")
|
||||
q = flag.String("q", "", "The query string")
|
||||
dest = flag.String("dest", "", "The ID of the BigQuery table to write the result to. If unset, an ephemeral table ID will be generated.")
|
||||
pollint = flag.Duration("pollint", 10*time.Second, "Polling interval for checking job status")
|
||||
wait = flag.Bool("wait", false, "Whether to wait for the query job to complete.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
flagsOk := true
|
||||
for _, f := range []string{"project", "dataset", "q"} {
|
||||
if flag.Lookup(f).Value.String() == "" {
|
||||
fmt.Fprintf(os.Stderr, "Flag --%s is required\n", f)
|
||||
flagsOk = false
|
||||
}
|
||||
}
|
||||
if !flagsOk {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
client, err := bigquery.NewClient(ctx, *project)
|
||||
if err != nil {
|
||||
log.Fatalf("Creating bigquery client: %v", err)
|
||||
}
|
||||
|
||||
query := client.Query(*q)
|
||||
query.DefaultProjectID = *project
|
||||
query.DefaultDatasetID = *dataset
|
||||
query.WriteDisposition = bigquery.WriteTruncate
|
||||
|
||||
if *dest != "" {
|
||||
query.Dst = client.Dataset(*dataset).Table(*dest)
|
||||
}
|
||||
|
||||
// Query data.
|
||||
job, err := query.Run(ctx)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Querying: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Submitted query. Job ID: %s\n", job.ID())
|
||||
if !*wait {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Waiting for job to complete.\n")
|
||||
|
||||
for range time.Tick(*pollint) {
|
||||
status, err := job.Status(ctx)
|
||||
if err != nil {
|
||||
fmt.Printf("Failure determining status: %v", err)
|
||||
break
|
||||
}
|
||||
if !status.Done() {
|
||||
continue
|
||||
}
|
||||
if err := status.Err(); err == nil {
|
||||
fmt.Printf("Success\n")
|
||||
} else {
|
||||
fmt.Printf("Failure: %+v\n", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
142
vendor/cloud.google.com/go/examples/bigquery/read/main.go
generated
vendored
Normal file
142
vendor/cloud.google.com/go/examples/bigquery/read/main.go
generated
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// read is an example client of the bigquery client library.
|
||||
// It reads from a table, returning the data via an Iterator.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"cloud.google.com/go/bigquery"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/api/iterator"
|
||||
)
|
||||
|
||||
var (
|
||||
project = flag.String("project", "", "The ID of a Google Cloud Platform project")
|
||||
dataset = flag.String("dataset", "", "The ID of a BigQuery dataset")
|
||||
table = flag.String("table", ".*", "A regular expression to match the IDs of tables to read.")
|
||||
jobID = flag.String("jobid", "", "The ID of a query job that has already been submitted."+
|
||||
" If set, --dataset, --table will be ignored, and results will be read from the specified job.")
|
||||
)
|
||||
|
||||
func printValues(ctx context.Context, it *bigquery.RowIterator) {
|
||||
// one-space padding.
|
||||
tw := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
for {
|
||||
var vals []bigquery.Value
|
||||
err := it.Next(&vals)
|
||||
if err == iterator.Done {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Printf("err calling get: %v\n", err)
|
||||
}
|
||||
sep := ""
|
||||
for _, v := range vals {
|
||||
fmt.Fprintf(tw, "%s%v", sep, v)
|
||||
sep = "\t"
|
||||
}
|
||||
fmt.Fprintf(tw, "\n")
|
||||
}
|
||||
tw.Flush()
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func printTable(ctx context.Context, client *bigquery.Client, t *bigquery.Table) {
|
||||
it := t.Read(ctx)
|
||||
id := t.FullyQualifiedName()
|
||||
fmt.Printf("%s\n%s\n", id, strings.Repeat("-", len(id)))
|
||||
printValues(ctx, it)
|
||||
}
|
||||
|
||||
func printQueryResults(ctx context.Context, client *bigquery.Client, queryJobID string) {
|
||||
job, err := client.JobFromID(ctx, queryJobID)
|
||||
if err != nil {
|
||||
log.Fatalf("Loading job: %v", err)
|
||||
}
|
||||
|
||||
it, err := job.Read(ctx)
|
||||
if err != nil {
|
||||
log.Fatalf("Reading: %v", err)
|
||||
}
|
||||
|
||||
// TODO: print schema.
|
||||
printValues(ctx, it)
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
flagsOk := true
|
||||
if flag.Lookup("project").Value.String() == "" {
|
||||
fmt.Fprintf(os.Stderr, "Flag --project is required\n")
|
||||
flagsOk = false
|
||||
}
|
||||
|
||||
var sourceFlagCount int
|
||||
if flag.Lookup("dataset").Value.String() != "" {
|
||||
sourceFlagCount++
|
||||
}
|
||||
if flag.Lookup("jobid").Value.String() != "" {
|
||||
sourceFlagCount++
|
||||
}
|
||||
if sourceFlagCount != 1 {
|
||||
fmt.Fprintf(os.Stderr, "Exactly one of --dataset or --jobid must be set\n")
|
||||
flagsOk = false
|
||||
}
|
||||
|
||||
if !flagsOk {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tableRE, err := regexp.Compile(*table)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "--table is not a valid regular expression: %q\n", *table)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
client, err := bigquery.NewClient(ctx, *project)
|
||||
if err != nil {
|
||||
log.Fatalf("Creating bigquery client: %v", err)
|
||||
}
|
||||
|
||||
if *jobID != "" {
|
||||
printQueryResults(ctx, client, *jobID)
|
||||
return
|
||||
}
|
||||
ds := client.Dataset(*dataset)
|
||||
tableIter := ds.Tables(context.Background())
|
||||
for {
|
||||
t, err := tableIter.Next()
|
||||
if err == iterator.Done {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("Listing tables: %v", err)
|
||||
}
|
||||
if tableRE.MatchString(t.TableID) {
|
||||
printTable(ctx, client, t)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue