Module: BigQuery::Jobs
- Included in:
- Client
- Defined in:
- lib/bigquery-client/jobs.rb
Instance Method Summary collapse
- #fetch_job(id, options = {}) ⇒ Object
- #jobs(options = {}) ⇒ Object
- #jobs_query(query, options = {}) ⇒ Object
- #load(options = {}) ⇒ Object
- #query_results(id, options = {}) ⇒ Object
- #sql(query, options = {}) ⇒ Object
Instance Method Details
#fetch_job(id, options = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/bigquery-client/jobs.rb', line 39 def fetch_job(id, = {}) access_api( api_method: bigquery.jobs.get, parameters: { jobId: id }.merge() ) end |
#jobs(options = {}) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/bigquery-client/jobs.rb', line 32 def jobs( = {}) access_api( api_method: bigquery.jobs.list, parameters: ) end |
#jobs_query(query, options = {}) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/bigquery-client/jobs.rb', line 13 def jobs_query(query, = {}) default = { query: query, timeoutMs: 600_000 } access_api( api_method: bigquery.jobs.query, body_object: default.merge() ) end |
#load(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bigquery-client/jobs.rb', line 21 def load( = {}) access_api( api_method: bigquery.jobs.insert, body_object: { configuration: { load: } } ) end |
#query_results(id, options = {}) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/bigquery-client/jobs.rb', line 46 def query_results(id, = {}) access_api( api_method: bigquery.jobs.get_query_results, parameters: { jobId: id }.merge() ) end |
#sql(query, options = {}) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/bigquery-client/jobs.rb', line 5 def sql(query, = {}) result = jobs_query(query, ) names = result['schema']['fields'].map {|field| field['name'] } types = result['schema']['fields'].map {|field| field['type'] } records = result['rows'].map {|row| row['f'].map {|record| record['v'] } } convert(records, types).map { |values| [names, values].transpose.to_h } end |