class Google::Cloud::Bigquery::CopyJob::Updater
Yielded to a block to accumulate changes for an API request.
Public Class Methods
@private Create an Updater
from an options hash.
@return [Google::Cloud::Bigquery::CopyJob::Updater] A job
configuration object for setting copy options.
# File lib/google/cloud/bigquery/copy_job.rb, line 156 def self.from_options service, source, target, options job_ref = service.job_ref_from options[:job_id], options[:prefix] copy_cfg = Google::Apis::BigqueryV2::JobConfigurationTableCopy.new( source_table: source, destination_table: target ) req = Google::Apis::BigqueryV2::Job.new( job_reference: job_ref, configuration: Google::Apis::BigqueryV2::JobConfiguration.new( copy: copy_cfg, dry_run: options[:dryrun] ) ) updater = CopyJob::Updater.new req updater.create = options[:create] updater.write = options[:write] updater.labels = options[:labels] if options[:labels] updater end
@private Create an Updater
object.
# File lib/google/cloud/bigquery/copy_job.rb, line 146 def initialize gapi super() @gapi = gapi end
Public Instance Methods
# File lib/google/cloud/bigquery/copy_job.rb, line 297 def cancel raise "not implemented in #{self.class}" end
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.
@param [String] new_create The new create disposition.
@!group Attributes
# File lib/google/cloud/bigquery/copy_job.rb, line 224 def create= new_create @gapi.configuration.copy.update! create_disposition: Convert.create_disposition(new_create) end
Sets the encryption configuration of the destination table.
@param [Google::Cloud::BigQuery::EncryptionConfiguration] val
Custom encryption configuration (e.g., Cloud KMS keys).
@example
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
@!group Attributes
# File lib/google/cloud/bigquery/copy_job.rb, line 268 def encryption= val @gapi.configuration.copy.update! destination_encryption_configuration: val.to_gapi end
Sets the labels to use for the job.
@param [Hash] value 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.
@!group Attributes
# File lib/google/cloud/bigquery/copy_job.rb, line 293 def labels= value @gapi.configuration.update! labels: value end
Sets the geographic location where the job should run. Required except for US and EU.
@param [String] value A geographic location, such as “US”, “EU” or
"asia-northeast1". Required except for US and EU.
@example
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
@!group Attributes
# File lib/google/cloud/bigquery/copy_job.rb, line 200 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
# File lib/google/cloud/bigquery/copy_job.rb, line 305 def reload! raise "not implemented in #{self.class}" end
# File lib/google/cloud/bigquery/copy_job.rb, line 301 def rerun! raise "not implemented in #{self.class}" end
@private Returns the Google
API client library version of this job.
@return [<Google::Apis::BigqueryV2::Job>] (See
{Google::Apis::BigqueryV2::Job})
# File lib/google/cloud/bigquery/copy_job.rb, line 319 def to_gapi @gapi end
# File lib/google/cloud/bigquery/copy_job.rb, line 310 def wait_until_done! raise "not implemented in #{self.class}" end
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.
@param [String] new_write The new write disposition.
@!group Attributes
# File lib/google/cloud/bigquery/copy_job.rb, line 244 def write= new_write @gapi.configuration.copy.update! write_disposition: Convert.write_disposition(new_write) end