Sha256: 43eed3606add79f74b8bc3a40b5b414bcb44cf6d9388c37fe6c3076b836dda06

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

require_relative '../command'

module AmazonAthena
  module Commands
    class ShowTableProperties < AmazonAthena::Command

      def initialize(database_table)
        @database_table = database_table
      end

      def statement
        "SHOW TBLPROPERTIES #{@database_table};"
      end

      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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
athena-cli-0.1.0 lib/amazon_athena/commands/show_table_properties.rb