Class: Presto::Client::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/presto/client/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



22
23
24
# File 'lib/presto/client/client.rb', line 22

def initialize(options)
  @options = options
end

Instance Method Details

#query(query, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/presto/client/client.rb', line 26

def query(query, &block)
  q = Query.start(query, @options)
  if block
    begin
      yield q
    ensure
      q.close
    end
  else
    return q
  end
end

#run(query) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/presto/client/client.rb', line 39

def run(query)
  q = Query.start(query, @options)
  begin
    columns = q.columns
    if columns.empty?
      return [], []
    end
    return columns, q.rows
  ensure
    q.close
  end
end