Class: Blazer::Adapters::DrillAdapter

Inherits:
BaseAdapter show all
Defined in:
lib/blazer/adapters/drill_adapter.rb

Instance Attribute Summary

Attributes inherited from BaseAdapter

#data_source

Instance Method Summary collapse

Methods inherited from BaseAdapter

#cachable?, #cancel, #cohort_analysis_statement, #cost, #explain, #initialize, #preview_statement, #reconnect, #schema, #supports_cohort_analysis?, #tables

Constructor Details

This class inherits a constructor from Blazer::Adapters::BaseAdapter

Instance Method Details

#parameter_bindingObject



27
28
29
# File 'lib/blazer/adapters/drill_adapter.rb', line 27

def parameter_binding
  # not supported
end

#quotingObject



22
23
24
# File 'lib/blazer/adapters/drill_adapter.rb', line 22

def quoting
  :single_quote_escape
end

#run_statement(statement, comment) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/blazer/adapters/drill_adapter.rb', line 4

def run_statement(statement, comment)
  columns = []
  rows = []
  error = nil

  begin
    # remove trailing semicolon
    response = drill.query(statement.sub(/;\s*\z/, ""))
    rows = response.map { |r| r.values }
    columns = rows.any? ? response.first.keys : []
  rescue => e
    error = e.message
  end

  [columns, rows, error]
end