Class: Zillabyte::API::Queries
- Defined in:
- lib/zillabyte/api/queries.rb
Instance Method Summary collapse
- #agnostic(expression, options = {}) ⇒ Object
- #pull_to_s3(query, options) ⇒ Object
-
#sql(expression, method, options = {}) ⇒ Object
GET /sql.
-
#sxp(expression, method, options = {}) ⇒ Object
GET /sxp.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Zillabyte::API::Base
Instance Method Details
#agnostic(expression, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/zillabyte/api/queries.rb', line 57 def agnostic(expression, = {}) case expression when Array res = sxp(expression, :post, ) when String res = sql(expression, :post, ) col_aliases = res["column_aliases"] #save the column aliases else throw "unknown expression type: #{expression}" end [:job_id] = res["job_id"] res = {'status' => nil} while(res['status'] != 'completed') res = sql(expression, :get, ) end res["return"]["column_aliases"] = col_aliases if col_aliases #send the column aliases back too res["return"] end |
#pull_to_s3(query, options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zillabyte/api/queries.rb', line 22 def pull_to_s3(query, ) = { 'query' => query }.merge() res = @api.request( :expects => 200, :method => :post, :path => "/query_pull_to_s3", :body => .to_json ) res.body end |
#sql(expression, method, options = {}) ⇒ Object
GET /sql
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/zillabyte/api/queries.rb', line 38 def sql(expression, method, = {}) = { 'sql' => expression }.merge() res = request( :expects => 200, :method => method, :path => "/query_sql", :body => .to_json ) res.body end |
#sxp(expression, method, options = {}) ⇒ Object
GET /sxp
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/zillabyte/api/queries.rb', line 5 def sxp(expression, method, = {}) = { 'sxp' => expression }.merge() res = request( :expects => 200, :method => method, :path => "/query_sxp", :body => .to_json ) res.body end |