Class: Gcloud::Bigquery::QueryJob
- Defined in:
- lib/gcloud/bigquery/query_job.rb
Overview
# QueryJob
A Job subclass representing a query operation that may be performed on a Table. A QueryJob instance is created when you call Project#query_job, Dataset#query_job, or View#data.
Instance Attribute Summary
Attributes inherited from Job
Instance Method Summary collapse
-
#batch? ⇒ Boolean
Checks if the priority for the query is ‘BATCH`.
-
#bytes_processed ⇒ Object
The number of bytes processed by the query.
-
#cache? ⇒ Boolean
Checks if the query job looks for an existing result in the query cache.
-
#cache_hit? ⇒ Boolean
Checks if the query results are from the query cache.
-
#destination ⇒ Object
The table in which the query results are stored.
-
#flatten? ⇒ Boolean
Checks if the query job flattens nested and repeated fields in the query results.
-
#interactive? ⇒ Boolean
Checks if the priority for the query is ‘INTERACTIVE`.
-
#large_results? ⇒ Boolean
Checks if the the query job allows arbitrarily large results at a slight cost to performance.
-
#query_results(token: nil, max: nil, start: nil, timeout: nil) ⇒ Gcloud::Bigquery::QueryData
Retrieves the query results for the job.
Methods inherited from Job
#configuration, #created_at, #done?, #ended_at, #error, #errors, #failed?, from_gapi, #initialize, #job_id, #pending?, #project_id, #reload!, #rerun!, #running?, #started_at, #state, #statistics, #status, #wait_until_done!
Constructor Details
This class inherits a constructor from Gcloud::Bigquery::Job
Instance Method Details
#batch? ⇒ Boolean
Checks if the priority for the query is ‘BATCH`.
34 35 36 37 |
# File 'lib/gcloud/bigquery/query_job.rb', line 34 def batch? val = @gapi.configuration.query.priority val == "BATCH" end |
#bytes_processed ⇒ Object
The number of bytes processed by the query.
84 85 86 87 88 |
# File 'lib/gcloud/bigquery/query_job.rb', line 84 def bytes_processed Integer @gapi.statistics.query.total_bytes_processed rescue nil end |
#cache? ⇒ Boolean
Checks if the query job looks for an existing result in the query cache. For more information, see [Query Caching](cloud.google.com/bigquery/querying-data#querycaching).
60 61 62 63 64 |
# File 'lib/gcloud/bigquery/query_job.rb', line 60 def cache? val = @gapi.configuration.query.use_query_cache return false if val.nil? val end |
#cache_hit? ⇒ Boolean
Checks if the query results are from the query cache.
78 79 80 |
# File 'lib/gcloud/bigquery/query_job.rb', line 78 def cache_hit? @gapi.statistics.query.cache_hit end |
#destination ⇒ Object
The table in which the query results are stored.
92 93 94 95 96 97 98 |
# File 'lib/gcloud/bigquery/query_job.rb', line 92 def destination table = @gapi.configuration.query.destination_table return nil unless table retrieve_table table.project_id, table.dataset_id, table.table_id end |
#flatten? ⇒ Boolean
Checks if the query job flattens nested and repeated fields in the query results. The default is ‘true`. If the value is `false`, #large_results? should return `true`.
70 71 72 73 74 |
# File 'lib/gcloud/bigquery/query_job.rb', line 70 def flatten? val = @gapi.configuration.query.flatten_results return true if val.nil? val end |
#interactive? ⇒ Boolean
Checks if the priority for the query is ‘INTERACTIVE`.
41 42 43 44 45 |
# File 'lib/gcloud/bigquery/query_job.rb', line 41 def interactive? val = @gapi.configuration.query.priority return true if val.nil? val == "INTERACTIVE" end |
#large_results? ⇒ Boolean
Checks if the the query job allows arbitrarily large results at a slight cost to performance.
50 51 52 53 54 |
# File 'lib/gcloud/bigquery/query_job.rb', line 50 def large_results? val = @gapi.configuration.query.allow_large_results return false if val.nil? val end |
#query_results(token: nil, max: nil, start: nil, timeout: nil) ⇒ Gcloud::Bigquery::QueryData
Retrieves the query results for the job.
129 130 131 132 133 134 |
# File 'lib/gcloud/bigquery/query_job.rb', line 129 def query_results token: nil, max: nil, start: nil, timeout: nil ensure_service! = { token: token, max: max, start: start, timeout: timeout } gapi = service.job_query_results job_id, QueryData.from_gapi gapi, service end |