Class: Blazer::Adapters::DrillAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- Blazer::Adapters::DrillAdapter
- Defined in:
- lib/blazer/adapters/drill_adapter.rb
Instance Attribute Summary
Attributes inherited from BaseAdapter
Instance Method Summary collapse
Methods inherited from BaseAdapter
#cachable?, #cancel, #cost, #explain, #initialize, #preview_statement, #reconnect, #schema, #tables
Constructor Details
This class inherits a constructor from Blazer::Adapters::BaseAdapter
Instance Method Details
#run_statement(statement, comment) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/blazer/adapters/drill_adapter.rb', line 4 def run_statement(statement, comment) columns = [] rows = [] error = nil header = {"Content-Type" => "application/json", "Accept" => "application/json"} data = { queryType: "sql", query: statement } uri = URI.parse("#{settings["url"]}/query.json") http = Net::HTTP.new(uri.host, uri.port) begin response = JSON.parse(http.post(uri.request_uri, data.to_json, header).body) if response["errorMessage"] error = response["errorMessage"] else columns = response["columns"] rows = response["rows"].map { |r| r.values } end rescue => e error = e. end [columns, rows, error] end |