Class: GoogleApis::Api::BigQuery
- Inherits:
-
Object
- Object
- GoogleApis::Api::BigQuery
- Extended by:
- Base
- Defined in:
- lib/google_apis/api/big_query.rb
Instance Method Summary collapse
- #dataset ⇒ Object
- #project ⇒ Object
- #select_rows(statement) ⇒ Object
- #select_value(query) ⇒ Object
- #select_values(query) ⇒ Object
Methods included from Base
Instance Method Details
#dataset ⇒ Object
15 16 17 |
# File 'lib/google_apis/api/big_query.rb', line 15 def dataset default_params[:datasetId] end |
#project ⇒ Object
11 12 13 |
# File 'lib/google_apis/api/big_query.rb', line 11 def project default_params[:projectId] end |
#select_rows(statement) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/google_apis/api/big_query.rb', line 19 def select_rows(statement) result = jobs.query :query => statement types = result["schema"]["fields"].collect{|x| x["type"].downcase.to_sym} (result["rows"] || []).collect do |row| row["f"].inject([]) do |values, x| values << parse_value(types[values.size], x["v"]) end end end |
#select_value(query) ⇒ Object
34 35 36 37 |
# File 'lib/google_apis/api/big_query.rb', line 34 def select_value(query) row = select_rows(query)[0] row[0] if row end |
#select_values(query) ⇒ Object
30 31 32 |
# File 'lib/google_apis/api/big_query.rb', line 30 def select_values(query) select_rows(query).collect{|x| x[0]} end |