Class: AmazonAthena::Partition

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

Instance Method Summary collapse

Constructor Details

#initialize(options: {}, location: nil) ⇒ Partition

Returns a new instance of Partition.



4
5
6
7
# File 'lib/amazon_athena/partition.rb', line 4

def initialize(options: {}, location: nil)
  @options = options
  @location = location
end

Instance Method Details

#to_sObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/amazon_athena/partition.rb', line 9

def to_s
  return nil if @options.empty?

  # TODO: Sanitize and handle non-strings
  opts = @options.map {|k,v| "#{k} = '#{v}'"}.join(", ")

  sql = "PARTITION (#{opts})"
  sql += " LOCATION '#{@location}'" if @location

  sql
end