Class: Gcloud::Bigquery::ExtractJob
- Defined in:
- lib/gcloud/bigquery/extract_job.rb
Overview
ExtractJob
A Job subclass representing an export operation that may be performed on a Table. A ExtractJob instance is created when you call Table#extract.
See Exporting Data From BigQuery and the Jobs API reference for details.
Instance Attribute Summary
Attributes inherited from Job
Instance Method Summary collapse
-
#avro? ⇒ Boolean
Checks if the destination format for the data is Avro.
-
#compression? ⇒ Boolean
Checks if the export operation compresses the data using gzip.
-
#csv? ⇒ Boolean
Checks if the destination format for the data is CSV.
-
#delimiter ⇒ Object
The symbol the operation uses to delimit fields in the exported data.
-
#destinations ⇒ Object
The URI or URIs representing the Google Cloud Storage files to which the data is exported.
-
#destinations_counts ⇒ Object
The count of files per destination URI or URI pattern specified in #destinations.
-
#destinations_file_counts ⇒ Object
The count of files per destination URI or URI pattern specified in #destinations.
-
#json? ⇒ Boolean
Checks if the destination format for the data is newline-delimited JSON.
-
#print_header? ⇒ Boolean
Checks if the exported data contains a header row.
-
#source ⇒ Object
The table from which the data is exported.
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
#avro? ⇒ Boolean
Checks if the destination format for the data is Avro. The default is false
.
77 78 79 80 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 77 def avro? val = config["extract"]["destinationFormat"] val == "AVRO" end |
#compression? ⇒ Boolean
Checks if the export operation compresses the data using gzip. The default is false
.
52 53 54 55 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 52 def compression? val = config["extract"]["compression"] val == "GZIP" end |
#csv? ⇒ Boolean
Checks if the destination format for the data is CSV. Tables with nested or repeated fields cannot be exported as CSV. The default is true
.
68 69 70 71 72 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 68 def csv? val = config["extract"]["destinationFormat"] return true if val.nil? val == "CSV" end |
#delimiter ⇒ Object
The symbol the operation uses to delimit fields in the exported data. The default is a comma (,).
85 86 87 88 89 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 85 def delimiter val = config["extract"]["fieldDelimiter"] val = "," if val.nil? val end |
#destinations ⇒ Object
The URI or URIs representing the Google Cloud Storage files to which the data is exported.
34 35 36 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 34 def destinations Array config["extract"]["destinationUris"] end |
#destinations_counts ⇒ Object
The count of files per destination URI or URI pattern specified in #destinations. Returns a Hash with the URI patterns as keys and the counts as values.
112 113 114 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 112 def destinations_counts Hash[destinations.zip destinations_file_counts] end |
#destinations_file_counts ⇒ Object
The count of files per destination URI or URI pattern specified in #destinations. Returns an Array of values in the same order as the URI patterns.
104 105 106 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 104 def destinations_file_counts Array stats["extract"]["destinationUriFileCounts"] end |
#json? ⇒ Boolean
Checks if the destination format for the data is newline-delimited JSON. The default is false
.
60 61 62 63 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 60 def json? val = config["extract"]["destinationFormat"] val == "NEWLINE_DELIMITED_JSON" end |
#print_header? ⇒ Boolean
Checks if the exported data contains a header row. The default is true
.
94 95 96 97 98 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 94 def print_header? val = config["extract"]["printHeader"] val = true if val.nil? val end |
#source ⇒ Object
The table from which the data is exported. This is the table upon which Table#extract was called. Returns a Table instance.
41 42 43 44 45 46 47 |
# File 'lib/gcloud/bigquery/extract_job.rb', line 41 def source table = config["extract"]["sourceTable"] return nil unless table retrieve_table table["projectId"], table["datasetId"], table["tableId"] end |