Class: AmazonAthena::Transformer

Inherits:
Object
  • Object
show all
Defined in:
lib/amazon_athena/transformer.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.transform_table(ddl, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/amazon_athena/transformer.rb', line 7

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