Business intelligence made simple
Use drill-sergeant for Apache Drill
Andrew Kane18ad8fb2288e
diff --git a/README.md b/README.mdindex 848d23e6..9ec4db12 100644--- a/README.md+++ b/README.md@@ -393,7 +393,7 @@ data_sources:- [Presto](#presto)- [MongoDB](#mongodb-1) [beta]- [Elasticsearch](#elasticsearch) [beta]-- [Apache Drill](#apache-drill-master) [beta]+- [Apache Drill](#apache-drill) [beta]You can also [create an adapter](#creating-an-adapter) for any other data store.@@ -491,12 +491,12 @@ Add [elasticsearch](https://github.com/elastic/elasticsearch-ruby) to your Gemfidata_sources:my_source:adapter: elasticsearch- url: http://user:password@hostname:9200/+ url: http://user:password@hostname:9200```-### Apache Drill [master]+### Apache Drill-Set:+Add [drill-sergeant](https://github.com/ankane/drill-sergeant) to your Gemfile and set:```ymldata_sources:diff --git a/app/views/blazer/queries/show.html.erb b/app/views/blazer/queries/show.html.erbindex 6a4d5357..1467a1e1 100644--- a/app/views/blazer/queries/show.html.erb+++ b/app/views/blazer/queries/show.html.erb@@ -62,7 +62,7 @@</script><% end %>-<% if %w[sql presto].include?(Blazer.data_sources[@query.data_source].adapter) %>+<% if %w[sql presto drill].include?(Blazer.data_sources[@query.data_source].adapter) %><script>// do not highlight really long queries// this can lead to performance issuesdiff --git a/lib/blazer/adapters/drill_adapter.rb b/lib/blazer/adapters/drill_adapter.rbindex 1ff5ba06..cf0bf526 100644--- a/lib/blazer/adapters/drill_adapter.rb+++ b/lib/blazer/adapters/drill_adapter.rb@@ -6,23 +6,11 @@ module Blazerrows = []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)-+ drill = ::Drill.new(url: settings["url"])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+ response = drill.query(statement)+ rows = response.map { |r| r.values }+ columns = rows.any? ? response.first.keys : []rescue => eerror = e.messageend