Sha256: a9cb79dfc95229b8d671fb9b0cb486deda898c23e3af873d5bfcf51487d8585f

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

require_relative '../command'
require_relative '../partition'

module AmazonAthena
  module Commands
    class AlterTableAddPartition < AmazonAthena::Command

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

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

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

      def run(connection)
        # TODO: Map fields directly
        connection.query(statement).raw_output
      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/alter_table_add_partition.rb