class AmazonAthena::Commands::ShowTableProperties

Public Class Methods

new(database_table) click to toggle source
# File lib/amazon_athena/commands/show_table_properties.rb, line 7
def initialize(database_table)
  @database_table = database_table
end

Public Instance Methods

run(connection) click to toggle source
# File lib/amazon_athena/commands/show_table_properties.rb, line 15
def run(connection)
  result = connection.query(statement).raw_output

  data = Hash[*result.split("\n").map {|line| line.split("\t")}.flatten]

  data[:name] = @database_table

  if type = data.delete('EXTERNAL')
    data[:external] = type
  end

  if last_modified = data.delete('transient_lastDdlTime')
    data[:last_modified] = Time.at(last_modified.to_i)
  end

  data
end
statement() click to toggle source
# File lib/amazon_athena/commands/show_table_properties.rb, line 11
def statement
  "SHOW TBLPROPERTIES #{@database_table};"
end