Class: Google::Cloud::Bigquery::CopyJob::Updater

Inherits:
Google::Cloud::Bigquery::CopyJob show all
Defined in:
lib/google/cloud/bigquery/copy_job.rb

Overview

Yielded to a block to accumulate changes for an API request.

Attributes collapse

Methods inherited from Google::Cloud::Bigquery::CopyJob

#create_if_needed?, #create_never?, #destination, #encryption, #source, #write_append?, #write_empty?, #write_truncate?

Methods inherited from Job

#configuration, #created_at, #delete, #done?, #ended_at, #error, #errors, #failed?, #job_id, #labels, #location, #num_child_jobs, #parent_job_id, #pending?, #project_id, #reservation_usage, #running?, #script_statistics, #session_id, #started_at, #state, #statistics, #status, #transaction_id, #user_email

Instance Method Details

#cancelObject



328
329
330
# File 'lib/google/cloud/bigquery/copy_job.rb', line 328

def cancel
  raise "not implemented in #{self.class}"
end

#create=(new_create) ⇒ Object

Sets the create disposition.

This specifies whether the job is allowed to create new tables. The default value is needed.

The following values are supported:

  • needed - Create the table if it does not exist.
  • never - The table must already exist. A 'notFound' error is raised if the table does not exist.

Parameters:

  • new_create (String)

    The new create disposition.



255
256
257
# File 'lib/google/cloud/bigquery/copy_job.rb', line 255

def create= new_create
  @gapi.configuration.copy.update! create_disposition: Convert.create_disposition(new_create)
end

#encryption=(val) ⇒ Object

Sets the encryption configuration of the destination table.

Examples:

require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
table = dataset.table "my_table"

key_name = "projects/a/locations/b/keyRings/c/cryptoKeys/d"
encrypt_config = bigquery.encryption kms_key: key_name
job = table.copy_job "my_dataset.new_table" do |job|
  job.encryption = encrypt_config
end

Parameters:

  • val (Google::Cloud::BigQuery::EncryptionConfiguration)

    Custom encryption configuration (e.g., Cloud KMS keys).



299
300
301
# File 'lib/google/cloud/bigquery/copy_job.rb', line 299

def encryption= val
  @gapi.configuration.copy.update! destination_encryption_configuration: val.to_gapi
end

#labels=(value) ⇒ Object

Sets the labels to use for the job.

Parameters:

  • value (Hash)

    A hash of user-provided labels associated with the job. You can use these to organize and group your jobs.

    The labels applied to a resource must meet the following requirements:

    • Each resource can have multiple labels, up to a maximum of 64.
    • Each label must be a key-value pair.
    • Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.
    • Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed.
    • The key portion of a label must be unique. However, you can use the same key with multiple resources.
    • Keys must start with a lowercase letter or international character.


324
325
326
# File 'lib/google/cloud/bigquery/copy_job.rb', line 324

def labels= value
  @gapi.configuration.update! labels: value
end

#location=(value) ⇒ Object

Sets the geographic location where the job should run. Required except for US and EU.

Examples:

require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
table = dataset.table "my_table"
destination_table = dataset.table "my_destination_table"

copy_job = table.copy_job destination_table do |j|
  j.location = "EU"
end

copy_job.wait_until_done!
copy_job.done? #=> true

Parameters:

  • value (String)

    A geographic location, such as "US", "EU" or "asia-northeast1". Required except for US and EU.



231
232
233
234
235
236
237
238
# File 'lib/google/cloud/bigquery/copy_job.rb', line 231

def location= value
  @gapi.job_reference.location = value
  return unless value.nil?

  # Treat assigning value of nil the same as unsetting the value.
  unset = @gapi.job_reference.instance_variables.include? :@location
  @gapi.job_reference.remove_instance_variable :@location if unset
end

#reload!Object Also known as: refresh!



336
337
338
# File 'lib/google/cloud/bigquery/copy_job.rb', line 336

def reload!
  raise "not implemented in #{self.class}"
end

#rerun!Object



332
333
334
# File 'lib/google/cloud/bigquery/copy_job.rb', line 332

def rerun!
  raise "not implemented in #{self.class}"
end

#wait_until_done!Object



341
342
343
# File 'lib/google/cloud/bigquery/copy_job.rb', line 341

def wait_until_done!
  raise "not implemented in #{self.class}"
end

#write=(new_write) ⇒ Object

Sets the write disposition.

This specifies how to handle data already present in the table. The default value is append.

The following values are supported:

  • truncate - BigQuery overwrites the table data.
  • append - BigQuery appends the data to the table.
  • empty - An error will be returned if the table already contains data.

Parameters:

  • new_write (String)

    The new write disposition.



275
276
277
# File 'lib/google/cloud/bigquery/copy_job.rb', line 275

def write= new_write
  @gapi.configuration.copy.update! write_disposition: Convert.write_disposition(new_write)
end