Class: AmazonAthena::Commands::AlterTableDropPartition

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

Instance Method Summary collapse

Methods inherited from AmazonAthena::Command

#preview

Constructor Details

#initialize(database_table, partitions) ⇒ AlterTableDropPartition

Returns a new instance of AlterTableDropPartition.



8
9
10
11
# File 'lib/amazon_athena/commands/alter_table_drop_partition.rb', line 8

def initialize(database_table, partitions)
  @database_table = database_table
  @partitions = partitions
end

Instance Method Details

#partition_clausesObject



13
14
15
# File 'lib/amazon_athena/commands/alter_table_drop_partition.rb', line 13

def partition_clauses
  @partitions.map {|p| "  #{p}"}.join(",\n")
end

#run(connection) ⇒ Object



21
22
23
24
# File 'lib/amazon_athena/commands/alter_table_drop_partition.rb', line 21

def run(connection)
  # TODO: Map fields directly
  connection.query(statement).raw_output
end

#statementObject



17
18
19
# File 'lib/amazon_athena/commands/alter_table_drop_partition.rb', line 17

def statement
  "ALTER TABLE #{@database_table} DROP\n#{partition_clauses};"
end