Class: Blazer::Adapters::HiveAdapter

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

Direct Known Subclasses

SparkAdapter

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, #reconnect, #schema, #supports_cohort_analysis?

Constructor Details

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

Instance Method Details

#parameter_bindingObject



35
36
# File 'lib/blazer/adapters/hive_adapter.rb', line 35

def parameter_binding
end

#preview_statementObject



24
25
26
# File 'lib/blazer/adapters/hive_adapter.rb', line 24

def preview_statement
  "SELECT * FROM {table} LIMIT 10"
end

#quotingObject



29
30
31
# File 'lib/blazer/adapters/hive_adapter.rb', line 29

def quoting
  :backslash_escape
end

#run_statement(statement, comment) ⇒ Object



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

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

  begin
    result = client.execute("#{statement} /*#{comment}*/")
    columns = result.any? ? result.first.keys : []
    rows = result.map(&:values)
  rescue => e
    error = e.message
  end

  [columns, rows, error]
end

#tablesObject



20
21
22
# File 'lib/blazer/adapters/hive_adapter.rb', line 20

def tables
  client.execute("SHOW TABLES").map { |r| r["tab_name"] }
end