Skip to content

Commit

Permalink
bigquery: include job creator email in Job representation.
Browse files Browse the repository at this point in the history
Change-Id: Ic4e7dd15ec8bff40739ed11630000e1322c21cff
Reviewed-on: https://code-review.googlesource.com/30630
Reviewed-by: kokoro <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>
  • Loading branch information
shollyman committed Jul 19, 2018
1 parent ffb8ba1 commit 7b18bf6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions bigquery/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (

// A Job represents an operation which has been submitted to BigQuery for processing.
type Job struct {
c *Client
projectID string
jobID string
location string

c *Client
projectID string
jobID string
location string
email string
config *bq.JobConfiguration
lastStatus *JobStatus
}
Expand Down Expand Up @@ -73,6 +73,11 @@ func (j *Job) Location() string {
return j.location
}

// Email returns the email of the job's creator.
func (j *Job) Email() string {
return j.email
}

// State is one of a sequence of states that a Job progresses through as it is processed.
type State int

Expand Down Expand Up @@ -620,7 +625,7 @@ func (it *JobIterator) fetch(pageSize int, pageToken string) (string, error) {
}

func convertListedJob(j *bq.JobListJobs, c *Client) (*Job, error) {
return bqToJob2(j.JobReference, j.Configuration, j.Status, j.Statistics, c)
return bqToJob2(j.JobReference, j.Configuration, j.Status, j.Statistics, j.UserEmail, c)
}

func (c *Client) getJobInternal(ctx context.Context, jobID, location string, fields ...googleapi.Field) (*bq.Job, error) {
Expand All @@ -644,15 +649,16 @@ func (c *Client) getJobInternal(ctx context.Context, jobID, location string, fie
}

func bqToJob(q *bq.Job, c *Client) (*Job, error) {
return bqToJob2(q.JobReference, q.Configuration, q.Status, q.Statistics, c)
return bqToJob2(q.JobReference, q.Configuration, q.Status, q.Statistics, q.UserEmail, c)
}

func bqToJob2(qr *bq.JobReference, qc *bq.JobConfiguration, qs *bq.JobStatus, qt *bq.JobStatistics, c *Client) (*Job, error) {
func bqToJob2(qr *bq.JobReference, qc *bq.JobConfiguration, qs *bq.JobStatus, qt *bq.JobStatistics, email string, c *Client) (*Job, error) {
j := &Job{
projectID: qr.ProjectId,
jobID: qr.JobId,
location: qr.Location,
c: c,
email: email,
}
j.setConfig(qc)
if err := j.setStatus(qs); err != nil {
Expand Down

0 comments on commit 7b18bf6

Please sign in to comment.