Class: AmazonAthena::Commands::AlterTableAddPartition

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

Instance Method Summary collapse

Methods inherited from AmazonAthena::Command

#preview

Constructor Details

#initialize(database_table, partitions) ⇒ AlterTableAddPartition

Returns a new instance of AlterTableAddPartition.



8
9
10
11
# File 'lib/amazon_athena/commands/alter_table_add_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_add_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_add_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_add_partition.rb', line 17

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