class Google::Cloud::Bigquery::Job::ScriptStatistics

Represents statistics for a child job of a script.

@attr_reader [String] evaluation_kind Indicates the type of child job. Possible values include `STATEMENT` and

`EXPRESSION`.

@attr_reader [Array<Google::Cloud::Bigquery::Job::ScriptStackFrame>] stack_frames Stack trace where the

current evaluation happened. Shows line/column/procedure name of each frame on the stack at the point where
the current evaluation happened. The leaf frame is first, the primary script is last.

@example

require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new

multi_statement_sql = <<~SQL
  -- Declare a variable to hold names as an array.
  DECLARE top_names ARRAY<STRING>;
  -- Build an array of the top 100 names from the year 2017.
  SET top_names = (
  SELECT ARRAY_AGG(name ORDER BY number DESC LIMIT 100)
  FROM `bigquery-public-data.usa_names.usa_1910_current`
  WHERE year = 2017
  );
  -- Which names appear as words in Shakespeare's plays?
  SELECT
  name AS shakespeare_name
  FROM UNNEST(top_names) AS name
  WHERE name IN (
  SELECT word
  FROM `bigquery-public-data.samples.shakespeare`
  );
SQL

job = bigquery.query_job multi_statement_sql

job.wait_until_done!

child_jobs = bigquery.jobs parent_job: job

child_jobs.each do |child_job|
  script_statistics = child_job.script_statistics
  puts script_statistics.evaluation_kind
  script_statistics.stack_frames.each do |stack_frame|
    puts stack_frame.text
  end
end

Attributes

evaluation_kind[R]
stack_frames[R]

Public Class Methods

from_gapi(gapi) click to toggle source

@private New ScriptStatistics from a statistics.script_statistics value.

# File lib/google/cloud/bigquery/job.rb, line 596
def self.from_gapi gapi
  frames = Array(gapi.stack_frames).map { |g| ScriptStackFrame.from_gapi g }
  new gapi.evaluation_kind, frames
end
new(evaluation_kind, stack_frames) click to toggle source

@private Creates a new ScriptStatistics instance.

# File lib/google/cloud/bigquery/job.rb, line 589
def initialize evaluation_kind, stack_frames
  @evaluation_kind = evaluation_kind
  @stack_frames = stack_frames
end