Class: Altertable::Lakehouse::QueryResult
- Inherits:
-
Object
- Object
- Altertable::Lakehouse::QueryResult
- Includes:
- Enumerable
- Defined in:
- lib/altertable/lakehouse/client.rb,
sig/altertable/lakehouse/client.rbs
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
metadata: the stream header object (first NDJSON line) columns: array of column name strings (second NDJSON line).
-
#metadata ⇒ Object
readonly
metadata: the stream header object (first NDJSON line) columns: array of column name strings (second NDJSON line).
Instance Method Summary collapse
- #each {|arg0| ... } ⇒ void
-
#initialize(enum) ⇒ QueryResult
constructor
A new instance of QueryResult.
Constructor Details
#initialize(enum) ⇒ QueryResult
Returns a new instance of QueryResult.
288 289 290 291 292 |
# File 'lib/altertable/lakehouse/client.rb', line 288 def initialize(enum) @enum = enum @metadata = nil @columns = nil end |
Instance Attribute Details
#columns ⇒ Object (readonly)
metadata: the stream header object (first NDJSON line) columns: array of column name strings (second NDJSON line)
286 287 288 |
# File 'lib/altertable/lakehouse/client.rb', line 286 def columns @columns end |
#metadata ⇒ Object (readonly)
metadata: the stream header object (first NDJSON line) columns: array of column name strings (second NDJSON line)
286 287 288 |
# File 'lib/altertable/lakehouse/client.rb', line 286 def @metadata end |
Instance Method Details
#each {|arg0| ... } ⇒ void
This method returns an undefined value.
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/altertable/lakehouse/client.rb', line 294 def each(&block) # The real mock streams: # line 1: { "statement":…, "session_id":…, … } (header object) # line 2: ["col1", "col2", …] (column names array) # line 3+: [val1, val2, …] (row value arrays) # We zip each row array with the column names to produce a Hash. line_index = 0 @enum.each do |item| case line_index when 0 @metadata = item when 1 @columns = item else if @columns.is_a?(Array) && item.is_a?(Array) block.call(@columns.zip(item).to_h) else block.call(item) end end line_index += 1 end end |