class Google::Cloud::Bigquery::QueryJob::Stage

Represents a stage in the execution plan for the query.

@attr_reader [Float] compute_ratio_avg Relative amount of time the

average shard spent on CPU-bound tasks.

@attr_reader [Float] compute_ratio_max Relative amount of time the

slowest shard spent on CPU-bound tasks.

@attr_reader [Integer] id Unique ID for the stage within the query

plan.

@attr_reader [String] name Human-readable name for the stage. @attr_reader [Float] read_ratio_avg Relative amount of time the

average shard spent reading input.

@attr_reader [Float] read_ratio_max Relative amount of time the

slowest shard spent reading input.

@attr_reader [Integer] records_read Number of records read into the

stage.

@attr_reader [Integer] records_written Number of records written by

the stage.

@attr_reader [Array<Step>] steps List of operations within the stage

in dependency order (approximately chronological).

@attr_reader [Float] wait_ratio_avg Relative amount of time the

average shard spent waiting to be scheduled.

@attr_reader [Float] wait_ratio_max Relative amount of time the

slowest shard spent waiting to be scheduled.

@attr_reader [Float] write_ratio_avg Relative amount of time the

average shard spent on writing output.

@attr_reader [Float] write_ratio_max Relative amount of time the

slowest shard spent on writing output.

@example

require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

sql = "SELECT word FROM `bigquery-public-data.samples.shakespeare`"
job = bigquery.query_job sql

job.wait_until_done!

stages = job.query_plan
stages.each do |stage|
  puts stage.name
  stage.steps.each do |step|
    puts step.kind
    puts step.substeps.inspect
  end
end

Attributes

compute_ratio_avg[R]
compute_ratio_max[R]
id[R]
name[R]
read_ratio_avg[R]
read_ratio_max[R]
records_read[R]
records_written[R]
status[R]
steps[R]
wait_ratio_avg[R]
wait_ratio_max[R]
write_ratio_avg[R]
write_ratio_max[R]

Public Class Methods

from_gapi(gapi) click to toggle source

@private New Stage from a statistics.query.queryPlan element.

# File lib/google/cloud/bigquery/query_job.rb, line 1681
def self.from_gapi gapi
  steps = Array(gapi.steps).map { |g| Step.from_gapi g }
  new gapi.compute_ratio_avg, gapi.compute_ratio_max, gapi.id, gapi.name, gapi.read_ratio_avg,
      gapi.read_ratio_max, gapi.records_read, gapi.records_written, gapi.status, steps, gapi.wait_ratio_avg,
      gapi.wait_ratio_max, gapi.write_ratio_avg, gapi.write_ratio_max
end
new(compute_ratio_avg, compute_ratio_max, id, name, read_ratio_avg, read_ratio_max, records_read, records_written, status, steps, wait_ratio_avg, wait_ratio_max, write_ratio_avg, write_ratio_max) click to toggle source

@private Creates a new Stage instance.

# File lib/google/cloud/bigquery/query_job.rb, line 1660
def initialize compute_ratio_avg, compute_ratio_max, id, name, read_ratio_avg, read_ratio_max, records_read,
               records_written, status, steps, wait_ratio_avg, wait_ratio_max, write_ratio_avg,
               write_ratio_max
  @compute_ratio_avg = compute_ratio_avg
  @compute_ratio_max = compute_ratio_max
  @id                = id
  @name              = name
  @read_ratio_avg    = read_ratio_avg
  @read_ratio_max    = read_ratio_max
  @records_read      = records_read
  @records_written   = records_written
  @status            = status
  @steps             = steps
  @wait_ratio_avg    = wait_ratio_avg
  @wait_ratio_max    = wait_ratio_max
  @write_ratio_avg   = write_ratio_avg
  @write_ratio_max   = write_ratio_max
end