Module: BigQuery::Client::Jobs

Included in:
BigQuery::Client
Defined in:
lib/big_query/client/jobs.rb

Instance Method Summary collapse

Instance Method Details

#get_query_results(id, opts = {}) ⇒ Hash

Gets the results of a given job

Parameters:

  • id (Integer)

    job id to fetch

  • options (Hash)

    bigquery opts accepted

Returns:

  • (Hash)

    json api response



32
33
34
35
36
37
# File 'lib/big_query/client/jobs.rb', line 32

def get_query_results(id, opts = {})
  opts['jobId'] ||= id

  api(api_method: @bq.jobs.get_query_results,
      parameters: opts)
end

#insert_job(opts, parameters = {}, media = nil) ⇒ Hash

Insert a job

Parameters:

  • options (Hash)

    hash of job options

  • parameters (Hash) (defaults to: {})

    hash of parameters (uploadType, etc.)

  • media (Google::APIClient::UploadIO) (defaults to: nil)

    media upload

Returns:

  • (Hash)

    json api response



45
46
47
48
49
50
# File 'lib/big_query/client/jobs.rb', line 45

def insert_job(opts, parameters = {}, media = nil)
  api(api_method: @bq.jobs.insert,
      parameters: parameters,
      body_object: {configuration: opts},
      media: media)
end

#job(id, opts = {}) ⇒ Hash

Fetches a bigquery job by id

Parameters:

  • id (Integer)

    job id to fetch

  • options (Hash)

    bigquery opts accepted

Returns:

  • (Hash)

    json api response



11
12
13
14
15
16
# File 'lib/big_query/client/jobs.rb', line 11

def job(id, opts = {})
  opts['jobId'] ||= id

  api(api_method: @bq.jobs.get,
      parameters: opts)
end

#jobs(opts = {}) ⇒ Hash

lists all the jobs

Parameters:

  • options (Hash)

    bigquery opts accepted

Returns:

  • (Hash)

    json api response



22
23
24
25
# File 'lib/big_query/client/jobs.rb', line 22

def jobs(opts = {})
  api(api_method: @bq.jobs.list,
      parameters: opts)
end