Class: AmazonAthena::Commands::ShowPartitions

Inherits:
AmazonAthena::Command show all
Defined in:
lib/amazon_athena/commands/show_partitions.rb

Instance Method Summary collapse

Methods inherited from AmazonAthena::Command

#preview

Constructor Details

#initialize(database_table) ⇒ ShowPartitions

Returns a new instance of ShowPartitions.



7
8
9
# File 'lib/amazon_athena/commands/show_partitions.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
# File 'lib/amazon_athena/commands/show_partitions.rb', line 15

def run(connection)
  # TODO: Map fields directly
  connection.query(statement).raw_output
rescue Exception => e
  case e.message
  when /not a partitioned table/
    "Error: #{@database_table} is not a partitioned table."
  end
end

#statementObject



11
12
13
# File 'lib/amazon_athena/commands/show_partitions.rb', line 11

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