Class: Gcloud::Bigquery::CopyJob

Inherits:
Job
  • Object
show all
Defined in:
lib/gcloud/bigquery/copy_job.rb

Overview

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.

See Copying an Existing Table and the Jobs API reference for details.

Instance Attribute Summary

Attributes inherited from Job

#connection, #gapi

Instance Method Summary collapse

Methods inherited from Job

#configuration, #created_at, #done?, #ended_at, #error, #errors, #failed?, from_gapi, #initialize, #job_id, #pending?, #project_id, #refresh!, #rerun!, #running?, #started_at, #state, #statistics, #status

Constructor Details

This class inherits a constructor from Gcloud::Bigquery::Job

Instance Method Details

#create_if_needed?Boolean

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.

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/gcloud/bigquery/copy_job.rb', line 56

def create_if_needed?
  disp = config["copy"]["createDisposition"]
  disp == "CREATE_IF_NEEDED"
end

#create_never?Boolean

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.

Returns:

  • (Boolean)


65
66
67
68
# File 'lib/gcloud/bigquery/copy_job.rb', line 65

def create_never?
  disp = config["copy"]["createDisposition"]
  disp == "CREATE_NEVER"
end

#destinationObject

The table to which data is copied. Returns a Table instance.



44
45
46
47
48
49
50
# File 'lib/gcloud/bigquery/copy_job.rb', line 44

def destination
  table = config["copy"]["destinationTable"]
  return nil unless table
  retrieve_table table["projectId"],
                 table["datasetId"],
                 table["tableId"]
end

#sourceObject

The table from which data is copied. This is the table on which Table#copy was called. Returns a Table instance.



34
35
36
37
38
39
40
# File 'lib/gcloud/bigquery/copy_job.rb', line 34

def source
  table = config["copy"]["sourceTable"]
  return nil unless table
  retrieve_table table["projectId"],
                 table["datasetId"],
                 table["tableId"]
end

#write_append?Boolean

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.

Returns:

  • (Boolean)


83
84
85
86
# File 'lib/gcloud/bigquery/copy_job.rb', line 83

def write_append?
  disp = config["copy"]["writeDisposition"]
  disp == "WRITE_APPEND"
end

#write_empty?Boolean

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.

Returns:

  • (Boolean)


92
93
94
95
# File 'lib/gcloud/bigquery/copy_job.rb', line 92

def write_empty?
  disp = config["copy"]["writeDisposition"]
  disp == "WRITE_EMPTY"
end

#write_truncate?Boolean

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.

Returns:

  • (Boolean)


74
75
76
77
# File 'lib/gcloud/bigquery/copy_job.rb', line 74

def write_truncate?
  disp = config["copy"]["writeDisposition"]
  disp == "WRITE_TRUNCATE"
end