Sha256: 96f539543c994464d5b82b0272311fcc0ff62378de42b039f1cc0463ca1190e6

Contents?: true

Size: 458 Bytes

Versions: 1

Compression:

Stored size: 458 Bytes

Contents

module AmazonAthena
  class Transformer

    TABLE_NAME_PATTERN = /CREATE EXTERNAL TABLE `(?<name>\S+)`/
    TABLE_LOCATION_PATTERN = /'(?<location>s3:\/\/\S+)'/

    def self.transform_table(ddl, options = {})
      if name = options[:name]
        ddl[TABLE_NAME_PATTERN] = "CREATE EXTERNAL TABLE `#{name}`"
      end

      if location = options[:location]
        ddl[TABLE_LOCATION_PATTERN] = "'s3://#{location}'"
      end

      ddl
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
athena-cli-0.1.0 lib/amazon_athena/transformer.rb