Class: Pinot::Response
- Inherits:
-
Object
- Object
- Pinot::Response
- Includes:
- Enumerable
- Defined in:
- lib/pinot/response.rb
Instance Method Summary collapse
- #columns ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(payload) ⇒ Response
constructor
A new instance of Response.
- #rows ⇒ Object
Constructor Details
#initialize(payload) ⇒ Response
Returns a new instance of Response.
5 6 7 |
# File 'lib/pinot/response.rb', line 5 def initialize(payload) @payload = payload end |
Instance Method Details
#columns ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pinot/response.rb', line 13 def columns names = @payload.dig("resultTable", "dataSchema", "columnNames") types = @payload.dig("resultTable", "dataSchema", "columnDataTypes") return {} if @payload["exceptions"].any? ix = 0 names ||= [] names.map do |name| ret = [name, types[ix]] ix += 1 ret end.to_h end |
#each(&block) ⇒ Object
26 27 28 29 30 |
# File 'lib/pinot/response.rb', line 26 def each(&block) rows.each do |row| block.call(row) end end |
#rows ⇒ Object
9 10 11 |
# File 'lib/pinot/response.rb', line 9 def rows @payload.dig("resultTable", "rows") end |