class Google::Cloud::Bigquery::Data


data = data.next if data.next?
# Retrieve the next page of results
end
puts row[:word]
data.each do |row|
# Iterate over the first page of results
data.total # 164656
data.count # 100000
data = job.data
job.wait_until_done!
job = bigquery.query_job sql
sql = “SELECT word FROM ‘bigquery-public-data.samples.shakespeare`”
bigquery = Google::Cloud::Bigquery.new
require “google/cloud/bigquery”
@example
query or table. See {Project#query}, {Dataset#query} and {Table#data}.
set metadata such as `total` and provide access to the schema of the
of rows in the page. In addition, methods of this class include result
delegates to Array, methods such as `Array#count` represent the number
Represents a page of results (rows) as an array of hashes. Because Data
# Data
#

def self.from_gapi_json gapi_json, table_gapi, job_gapi, service, format_options_use_int64_timestamp

Other tags:
    Private: - New Data from a response object.
def self.from_gapi_json gapi_json, table_gapi, job_gapi, service, format_options_use_int64_timestamp
  rows = gapi_json[:rows] || []
  rows = Convert.format_rows rows, table_gapi.schema.fields unless rows.empty?
  data = new rows
  data.table_gapi = table_gapi
  data.gapi_json = gapi_json
  data.job_gapi = job_gapi
  data.service = service
  data.format_options_use_int64_timestamp = format_options_use_int64_timestamp
  data
end

def all request_limit: nil, &block

Other tags:
    Example: Limit the number of API calls made: -
    Example: Using the enumerator by not passing a block: -
    Example: Iterating each rows by passing a block: -

Returns:
  • (Enumerator) - An enumerator providing access to all of the

Other tags:
    Yieldparam: row - The row object.

Other tags:
    Yield: - The block for accessing each row of data.

Parameters:
  • request_limit (Integer) -- The upper limit of API requests to make
def all request_limit: nil, &block
  request_limit = request_limit.to_i if request_limit
  return enum_for :all, request_limit: request_limit unless block_given?
  results = self
  loop do
    results.each(&block)
    if request_limit
      request_limit -= 1
      break if request_limit.negative?
    end
    break unless results.next?
    results = results.next
  end
end

def ddl?

Returns:
  • (Boolean) -

Other tags:
    See: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language -
def ddl?
  [
    "ALTER_TABLE",
    "CREATE_MODEL",
    "CREATE_TABLE",
    "CREATE_TABLE_AS_SELECT",
    "CREATE_VIEW",
    "DROP_MODEL",
    "DROP_TABLE",
    "DROP_VIEW"
  ].include? statement_type
end

def ddl_operation_performed

Returns:
  • (String, nil) - The DDL operation performed.
def ddl_operation_performed
  job_gapi&.statistics&.query&.ddl_operation_performed
end

def ddl_target_routine

Returns:
  • (Google::Cloud::Bigquery::Routine, nil) - The DDL target routine, in
def ddl_target_routine
  ensure_service!
  routine = job_gapi&.statistics&.query&.ddl_target_routine
  return nil if routine.nil?
  Google::Cloud::Bigquery::Routine.new_reference_from_gapi routine, service
end

def ddl_target_table

Returns:
  • (Google::Cloud::Bigquery::Table, nil) - The DDL target table, in
def ddl_target_table
  ensure_service!
  table = job_gapi&.statistics&.query&.ddl_target_table
  return nil if table.nil?
  Google::Cloud::Bigquery::Table.new_reference_from_gapi table, service
end

def deleted_row_count

Returns:
  • (Integer, nil) - The number of deleted rows, or `nil` if not
def deleted_row_count
  job_gapi&.statistics&.query&.dml_stats&.deleted_row_count
end

def dml?

Returns:
  • (Boolean) -

Other tags:
    See: https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax -
def dml?
  [
    "INSERT",
    "UPDATE",
    "MERGE",
    "DELETE"
  ].include? statement_type
end

def ensure_service!

Raise an error unless an active service is available.
#
def ensure_service!
  raise "Must have active connection" unless service
end

def etag

Returns:
  • (String) - The ETag hash.
def etag
  @gapi_json[:etag]
end

def fields

Returns:
  • (Array) - An array of field objects.
def fields
  schema.fields
end

def headers

Returns:
  • (Array) - An array of column names.
def headers
  schema.headers
end

def initialize arr = []

Other tags:
    Private: -
def initialize arr = []
  @service = nil
  @table_gapi = nil
  @gapi_json = nil
  super arr
end

def inserted_row_count

Returns:
  • (Integer, nil) - The number of inserted rows, or `nil` if not
def inserted_row_count
  job_gapi&.statistics&.query&.dml_stats&.inserted_row_count
end

def kind

Returns:
  • (String) - The resource type.
def kind
  @gapi_json[:kind]
end

def next

Returns:
  • (Data) - A new instance providing the next page of data.
def next
  return nil unless next?
  ensure_service!
  data_json = service.list_tabledata \
    @table_gapi.table_reference.dataset_id,
    @table_gapi.table_reference.table_id,
    token: token,
    format_options_use_int64_timestamp: @format_options_use_int64_timestamp
  self.class.from_gapi_json data_json, @table_gapi, job_gapi, @service, @format_options_use_int64_timestamp
end

def next?

Returns:
  • (Boolean) - `true` when there is a next page, `false` otherwise.
def next?
  !token.nil?
end

def num_dml_affected_rows

Returns:
  • (Integer, nil) - The number of rows affected by a DML statement,
def num_dml_affected_rows
  job_gapi&.statistics&.query&.num_dml_affected_rows
end

def param_types

Returns:
  • (Hash) - A hash with field names as keys, and types as values.
def param_types
  schema.param_types
end

def schema

Returns:
  • (Schema) - A schema object.
def schema
  return nil unless @table_gapi
  Schema.from_gapi(@table_gapi.schema).freeze
end

def statement_type

Returns:
  • (String, nil) - The type of query statement.
def statement_type
  job_gapi&.statistics&.query&.statement_type
end

def token

Returns:
  • (String) - The pagination token.
def token
  @gapi_json[:pageToken]
end

def total

Returns:
  • (Integer) - The number of rows.
def total
  Integer @gapi_json[:totalRows]
rescue StandardError
  nil
end

def updated_row_count

Returns:
  • (Integer, nil) - The number of updated rows, or `nil` if not
def updated_row_count
  job_gapi&.statistics&.query&.dml_stats&.updated_row_count
end