Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into shim_publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdiep committed Dec 9, 2020
2 parents 8d42ca8 + 0443e47 commit a34e44b
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release-submodule.yaml
Expand Up @@ -75,9 +75,9 @@ jobs:
package-name: ${{ matrix.package }}
monorepo-tags: true
command: release-pr
- id: label # Adds the "autorelease: pending" label.
if: ${{steps.release-please.outputs.pr}})
uses: actions/github-script@v3
- uses: actions/github-script@v3
id: label # Adds the "autorelease: pending" label.
if: ${{steps.release-please.outputs.pr}}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yaml
@@ -1,6 +1,7 @@
# This workflow creates release PRs and tags the top level release for
# the top level repository:
push:
on:
push:
branches:
- master
name: release-please
Expand All @@ -17,9 +18,9 @@ jobs:
fork: true
package-name: google-cloud-go
command: release-pr
- id: label # Add the magic "autorelease: pending" label.
- uses: actions/github-script@v3
id: label # Add the magic "autorelease: pending" label.
if: ${{ steps.release-pr.outputs.pr }}
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
Expand Down
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -175,3 +175,11 @@ for more information.
[cloud-video]: https://cloud.google.com/video-intelligence/
[cloud-vision]: https://cloud.google.com/vision
[cloud-webrisk]: https://cloud.google.com/web-risk/

## Links

- [Go on Google Cloud](https://cloud.google.com/go/home)
- [Getting started with Go on Google Cloud](https://cloud.google.com/go/getting-started)
- [App Engine Quickstart](https://cloud.google.com/appengine/docs/standard/go/quickstart)
- [Cloud Functions Quickstart](https://cloud.google.com/functions/docs/quickstart-go)
- [Cloud Run Quickstart](https://cloud.google.com/run/docs/quickstarts/build-and-deploy#go)
57 changes: 57 additions & 0 deletions bigquery/integration_test.go
Expand Up @@ -1630,6 +1630,63 @@ func TestIntegration_TableUpdate(t *testing.T) {
}
}

func TestIntegration_QueryStatistics(t *testing.T) {
// Make a bunch of assertions on a simple query.
if client == nil {
t.Skip("Integration tests skipped")
}
ctx := context.Background()

q := client.Query("SELECT 17 as foo, 3.14 as bar")
// disable cache to ensure we have query statistics
q.DisableQueryCache = true

job, err := q.Run(ctx)
if err != nil {
t.Fatalf("job Run failure: %v", err)
}
status, err := job.Wait(ctx)
if err != nil {
t.Fatalf("job Wait failure: %v", err)
}
if status.Statistics == nil {
t.Fatal("expected job statistics, none found")
}

if status.Statistics.NumChildJobs != 0 {
t.Errorf("expected no children, %d reported", status.Statistics.NumChildJobs)
}

if status.Statistics.ParentJobID != "" {
t.Errorf("expected no parent, but parent present: %s", status.Statistics.ParentJobID)
}

if status.Statistics.Details == nil {
t.Fatal("expected job details, none present")
}

qStats, ok := status.Statistics.Details.(*QueryStatistics)
if !ok {
t.Fatalf("expected query statistics not present")
}

if qStats.CacheHit {
t.Error("unexpected cache hit")
}

if qStats.StatementType != "SELECT" {
t.Errorf("expected SELECT statement type, got: %s", qStats.StatementType)
}

if len(qStats.QueryPlan) == 0 {
t.Error("expected query plan, none present")
}

if len(qStats.Timeline) == 0 {
t.Error("expected query timeline, none present")
}
}

func TestIntegration_Load(t *testing.T) {
if client == nil {
t.Skip("Integration tests skipped")
Expand Down
23 changes: 23 additions & 0 deletions bigquery/job.go
Expand Up @@ -347,6 +347,9 @@ type JobStatistics struct {
// ScriptStatistics includes information run as part of a child job within
// a script.
ScriptStatistics *ScriptStatistics

// ReservationUsage attributes slot consumption to reservations.
ReservationUsage []*ReservationUsage
}

// Statistics is one of ExtractStatistics, LoadStatistics or QueryStatistics.
Expand Down Expand Up @@ -561,6 +564,25 @@ type QueryTimelineSample struct {
SlotMillis int64
}

// ReservationUsage contains information about a job's usage of a single reservation.
type ReservationUsage struct {
// SlotMillis reports the slot milliseconds utilized within in the given reservation.
SlotMillis int64
// Name indicates the utilized reservation name, or "unreserved" for ondemand usage.
Name string
}

func bqToReservationUsage(ru []*bq.JobStatisticsReservationUsage) []*ReservationUsage {
var usage []*ReservationUsage
for _, in := range ru {
usage = append(usage, &ReservationUsage{
SlotMillis: in.SlotMs,
Name: in.Name,
})
}
return usage
}

// ScriptStatistics report information about script-based query jobs.
type ScriptStatistics struct {
EvaluationKind string
Expand Down Expand Up @@ -810,6 +832,7 @@ func (j *Job) setStatistics(s *bq.JobStatistics, c *Client) {
NumChildJobs: s.NumChildJobs,
ParentJobID: s.ParentJobId,
ScriptStatistics: bqToScriptStatistics(s.ScriptStatistics),
ReservationUsage: bqToReservationUsage(s.ReservationUsage),
}
switch {
case s.Extract != nil:
Expand Down
1 change: 1 addition & 0 deletions spanner/spannertest/README.md
Expand Up @@ -18,6 +18,7 @@ Here's a list of features that are missing or incomplete. It is roughly ordered
by ascending esotericism:

- expression functions
- NUMERIC
- more aggregation functions
- SELECT HAVING
- case insensitivity
Expand Down
3 changes: 2 additions & 1 deletion spanner/spansql/parser.go
Expand Up @@ -1650,6 +1650,7 @@ var baseTypes = map[string]TypeBase{
"BOOL": Bool,
"INT64": Int64,
"FLOAT64": Float64,
"NUMERIC": Numeric,
"STRING": String,
"BYTES": Bytes,
"DATE": Date,
Expand All @@ -1664,7 +1665,7 @@ func (p *parser) parseType() (Type, *parseError) {
ARRAY< scalar_type >
scalar_type:
{ BOOL | INT64 | FLOAT64 | STRING( length ) | BYTES( length ) | DATE | TIMESTAMP }
{ BOOL | INT64 | FLOAT64 | NUMERIC | STRING( length ) | BYTES( length ) | DATE | TIMESTAMP }
length:
{ int64_value | MAX }
*/
Expand Down
2 changes: 2 additions & 0 deletions spanner/spansql/sql.go
Expand Up @@ -234,6 +234,8 @@ func (tb TypeBase) SQL() string {
return "INT64"
case Float64:
return "FLOAT64"
case Numeric:
return "NUMERIC"
case String:
return "STRING"
case Bytes:
Expand Down
3 changes: 2 additions & 1 deletion spanner/spansql/types.go
Expand Up @@ -293,7 +293,7 @@ func (Check) isConstraint() {}
// Type represents a column type.
type Type struct {
Array bool
Base TypeBase // Bool, Int64, Float64, String, Bytes, Date, Timestamp
Base TypeBase // Bool, Int64, Float64, Numeric, String, Bytes, Date, Timestamp
Len int64 // if Base is String or Bytes; may be MaxLen
}

Expand All @@ -306,6 +306,7 @@ const (
Bool TypeBase = iota
Int64
Float64
Numeric
String
Bytes
Date
Expand Down

0 comments on commit a34e44b

Please sign in to comment.