Class: Redshifter::ExtractAndReplaceRedshiftTable

Inherits:
Object
  • Object
show all
Defined in:
lib/redshifter/extract_and_replace_redshift_table.rb

Instance Method Summary collapse

Constructor Details

#initialize(table, s3_util = Util::S3.new) ⇒ ExtractAndReplaceRedshiftTable

Returns a new instance of ExtractAndReplaceRedshiftTable.



3
4
5
6
# File 'lib/redshifter/extract_and_replace_redshift_table.rb', line 3

def initialize(table, s3_util = Util::S3.new)
  @table = table
  @s3_util = s3_util
end

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/redshifter/extract_and_replace_redshift_table.rb', line 8

def run
  extracted_s3_urls = Util::ExtractAndTransformUpdates
    .new(table: table,
         since: Table::EPOCH_TIMESTAMP,
         s3_util: s3_util
    ).run

  if extracted_s3_urls.any?
    manifest_url = Util::S3ManifestWriter
      .new(file_name: "#{SecureRandom.uuid}.manifest",
           file_urls: extracted_s3_urls,
           s3_util: s3_util
      ).run

    Util::CreateOrReplaceTable
      .new(table: table,
           manifest_url: manifest_url
      ).run
  end
end