class Google::Cloud::Bigquery::CopyJob

# CopyJob

A {Job} subclass representing a copy operation that may be performed on a {Table}. A CopyJob instance is created when you call {Table#copy_job}.

@see cloud.google.com/bigquery/docs/tables#copy-table Copying

an Existing Table

@see cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API

reference

@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

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

Public Instance Methods

create_if_needed?() click to toggle source

Checks if the create disposition for the job is `CREATE_IF_NEEDED`, which provides the following behavior: If the table does not exist, the copy operation creates the table. This is the default create disposition for copy jobs.

@return [Boolean] `true` when `CREATE_IF_NEEDED`, `false` otherwise.

# File lib/google/cloud/bigquery/copy_job.rb, line 76
def create_if_needed?
  disp = @gapi.configuration.copy.create_disposition
  disp == "CREATE_IF_NEEDED"
end
create_never?() click to toggle source

Checks if the create disposition for the job is `CREATE_NEVER`, which provides the following behavior: The table must already exist; if it does not, an error is returned in the job result.

@return [Boolean] `true` when `CREATE_NEVER`, `false` otherwise.

# File lib/google/cloud/bigquery/copy_job.rb, line 88
def create_never?
  disp = @gapi.configuration.copy.create_disposition
  disp == "CREATE_NEVER"
end
destination() click to toggle source

The table to which data is copied.

@return [Table] A table instance.

# File lib/google/cloud/bigquery/copy_job.rb, line 62
def destination
  table = @gapi.configuration.copy.destination_table
  return nil unless table
  retrieve_table table.project_id, table.dataset_id, table.table_id
end
encryption() click to toggle source

The encryption configuration of the destination table.

@return [Google::Cloud::BigQuery::EncryptionConfiguration] Custom

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

@!group Attributes

# File lib/google/cloud/bigquery/copy_job.rb, line 137
def encryption
  EncryptionConfiguration.from_gapi @gapi.configuration.copy.destination_encryption_configuration
end
source() click to toggle source

The table from which data is copied. This is the table on which {Table#copy_job} was called.

@return [Table] A table instance.

# File lib/google/cloud/bigquery/copy_job.rb, line 51
def source
  table = @gapi.configuration.copy.source_table
  return nil unless table
  retrieve_table table.project_id, table.dataset_id, table.table_id
end
write_append?() click to toggle source

Checks if the write disposition for the job is `WRITE_APPEND`, which provides the following behavior: If the table already exists, the copy operation appends the data to the table.

@return [Boolean] `true` when `WRITE_APPEND`, `false` otherwise.

# File lib/google/cloud/bigquery/copy_job.rb, line 112
def write_append?
  disp = @gapi.configuration.copy.write_disposition
  disp == "WRITE_APPEND"
end
write_empty?() click to toggle source

Checks if the write disposition for the job is `WRITE_EMPTY`, which provides the following behavior: If the table already exists and contains data, the job will have an error. This is the default write disposition for copy jobs.

@return [Boolean] `true` when `WRITE_EMPTY`, `false` otherwise.

# File lib/google/cloud/bigquery/copy_job.rb, line 125
def write_empty?
  disp = @gapi.configuration.copy.write_disposition
  disp == "WRITE_EMPTY"
end
write_truncate?() click to toggle source

Checks if the write disposition for the job is `WRITE_TRUNCATE`, which provides the following behavior: If the table already exists, the copy operation overwrites the table data.

@return [Boolean] `true` when `WRITE_TRUNCATE`, `false` otherwise.

# File lib/google/cloud/bigquery/copy_job.rb, line 100
def write_truncate?
  disp = @gapi.configuration.copy.write_disposition
  disp == "WRITE_TRUNCATE"
end