123456789101112131415161718192021222324252627282930 |
- module Blazer
- module Adapters
- class DrillAdapter < BaseAdapter
- 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)
- columns = response["columns"]
- rows = response["rows"].map { |r| r.values }
- rescue => e
- error = e.message
- end
- [columns, rows, error]
- end
- end
- end
- end
|