Class: Altertable::Lakehouse::QueryResult

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/altertable/lakehouse/client.rb,
sig/altertable/lakehouse/client.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enum) ⇒ QueryResult

Returns a new instance of QueryResult.

Parameters:

  • enum (Enumerator[untyped, untyped])


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

#columnsObject (readonly)

metadata: the stream header object (first NDJSON line) columns: array of column name strings (second NDJSON line)

Returns:

  • (Object)


286
287
288
# File 'lib/altertable/lakehouse/client.rb', line 286

def columns
  @columns
end

#metadataObject (readonly)

metadata: the stream header object (first NDJSON line) columns: array of column name strings (second NDJSON line)

Returns:

  • (Object)


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.

Yields:

Yield Parameters:

  • arg0 (Object)

Yield Returns:

  • (void)


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