Class: Yancya::BigQuery::Job
- Inherits:
-
Object
- Object
- Yancya::BigQuery::Job
- Defined in:
- lib/yancya/big_query/job.rb
Instance Method Summary collapse
-
#all_query_results ⇒ Object
caution: This method might return huge results.
- #errors ⇒ Object
-
#initialize(resource:, bq:) ⇒ Job
constructor
A new instance of Job.
- #job_id ⇒ Object
- #project_id ⇒ Object
- #query ⇒ Object
- #query_results ⇒ Object
- #reload ⇒ Object
- #state ⇒ Object
Constructor Details
#initialize(resource:, bq:) ⇒ Job
4 5 6 7 |
# File 'lib/yancya/big_query/job.rb', line 4 def initialize(resource:, bq:) @resource = resource @jobs = BigQuery::Jobs.new(bq: bq) end |
Instance Method Details
#all_query_results ⇒ Object
caution: This method might return huge results
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yancya/big_query/job.rb', line 25 def all_query_results loop.reduce([]) do |ary, _| ary.tap do |a| a << @jobs.get_query_results( project_id: project_id, job_id: job_id, page_token: (ary.last||{})["pageToken"] ) end if (ary.last||{})["pageToken"].nil? break ary else ary end end end |
#errors ⇒ Object
63 64 65 |
# File 'lib/yancya/big_query/job.rb', line 63 def errors status["errors"] end |
#job_id ⇒ Object
51 52 53 |
# File 'lib/yancya/big_query/job.rb', line 51 def job_id job_reference["jobId"] end |
#project_id ⇒ Object
47 48 49 |
# File 'lib/yancya/big_query/job.rb', line 47 def project_id job_reference["projectId"] end |
#query ⇒ Object
55 56 57 |
# File 'lib/yancya/big_query/job.rb', line 55 def query (configuration["query"]||{})["query"] end |
#query_results ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/yancya/big_query/job.rb', line 9 def query_results @jobs.get_query_results( project_id: project_id, job_id: job_id ).tap do |qr| if qr["pageToken"] warn " This is a slice in all results.\n You have not took rest results.\n Perhaps all_query_results is useful.\n TEXT\n end\n end\nend\n" |
#reload ⇒ Object
43 44 45 |
# File 'lib/yancya/big_query/job.rb', line 43 def reload @jobs.get(project_id: project_id, job_id: job_id) end |
#state ⇒ Object
59 60 61 |
# File 'lib/yancya/big_query/job.rb', line 59 def state status["state"] end |