Class: AmazonAthena::Commands::ShowTableProperties
- Inherits:
-
AmazonAthena::Command
- Object
- AmazonAthena::Command
- AmazonAthena::Commands::ShowTableProperties
- Defined in:
- lib/amazon_athena/commands/show_table_properties.rb
Instance Method Summary collapse
-
#initialize(database_table) ⇒ ShowTableProperties
constructor
A new instance of ShowTableProperties.
- #run(connection) ⇒ Object
- #statement ⇒ Object
Methods inherited from AmazonAthena::Command
Constructor Details
#initialize(database_table) ⇒ ShowTableProperties
Returns a new instance of ShowTableProperties.
7 8 9 |
# File 'lib/amazon_athena/commands/show_table_properties.rb', line 7 def initialize(database_table) @database_table = database_table end |
Instance Method Details
#run(connection) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 ⇒ Object
11 12 13 |
# File 'lib/amazon_athena/commands/show_table_properties.rb', line 11 def statement "SHOW TBLPROPERTIES #{@database_table};" end |