class Egis::QueryStatus

@!attribute [r] id

@return [String] Athena query execution ID

@!attribute [r] status

@return [:queued, :running, :finished, :failed, :cancelled]

@!attribute [r] message

@return [String]

@!attribute [r] output_location

@return [Egis::OutputLocation]

Constants

CANCELLED
FAILED
FINISHED
QUEUED
RUNNING
STATUSES

Attributes

id[R]
message[R]
output_downloader[R]
output_location[R]
output_parser[R]
status[R]

Public Class Methods

new(id, status, message, output_location, client: Egis::Client.new, output_downloader: Egis::OutputDownloader.new(client.aws_s3_client), output_parser: Egis::OutputParser.new) click to toggle source
# File lib/egis/query_status.rb, line 25
def initialize(id, status, message, output_location,
               client: Egis::Client.new,
               output_downloader: Egis::OutputDownloader.new(client.aws_s3_client),
               output_parser: Egis::OutputParser.new)
  raise ArgumentError, "Unsupported status #{status}" unless STATUSES.include?(status)

  @id = id
  @status = status
  @message = message
  @output_location = output_location
  @output_downloader = output_downloader
  @output_parser = output_parser
end

Public Instance Methods

cancelled?() click to toggle source
# File lib/egis/query_status.rb, line 55
def cancelled?
  status == CANCELLED
end
failed?() click to toggle source
# File lib/egis/query_status.rb, line 43
def failed?
  status == FAILED
end
fetch_result(schema: []) click to toggle source

Download query result.

By default, Egis will just parse output CSV and return array of string arrays. Additionally, you can pass expected query result column types to parse them into Ruby objects accordingly.

@param [Array] schema Array with expected query column types @return [Array] Array of row values

# File lib/egis/query_status.rb, line 72
def fetch_result(schema: [])
  output = output_downloader.download(output_location)
  output_parser.parse(output, schema)
end
finished?() click to toggle source
# File lib/egis/query_status.rb, line 39
def finished?
  status == FINISHED
end
in_progress?() click to toggle source
# File lib/egis/query_status.rb, line 59
def in_progress?
  [RUNNING, QUEUED].include?(status)
end
queued?() click to toggle source
# File lib/egis/query_status.rb, line 47
def queued?
  status == QUEUED
end
running?() click to toggle source
# File lib/egis/query_status.rb, line 51
def running?
  status == RUNNING
end