Class: RedshiftExtractor::Copy

Inherits:
Object
  • Object
show all
Defined in:
lib/redshift_extractor/copy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Copy

Returns a new instance of Copy.



5
6
7
8
9
10
11
# File 'lib/redshift_extractor/copy.rb', line 5

def initialize(args)
  @aws_access_key_id = args.fetch(:aws_access_key_id)
  @aws_secret_access_key = args.fetch(:aws_secret_access_key)
  @data_source = args.fetch(:data_source)
  @destination_schema = args.fetch(:destination_schema)
  @destination_table = args.fetch(:destination_table)
end

Instance Attribute Details

#aws_access_key_idObject (readonly)

Returns the value of attribute aws_access_key_id.



3
4
5
# File 'lib/redshift_extractor/copy.rb', line 3

def aws_access_key_id
  @aws_access_key_id
end

#aws_secret_access_keyObject (readonly)

Returns the value of attribute aws_secret_access_key.



3
4
5
# File 'lib/redshift_extractor/copy.rb', line 3

def aws_secret_access_key
  @aws_secret_access_key
end

#data_sourceObject (readonly)

Returns the value of attribute data_source.



3
4
5
# File 'lib/redshift_extractor/copy.rb', line 3

def data_source
  @data_source
end

#destination_schemaObject (readonly)

Returns the value of attribute destination_schema.



3
4
5
# File 'lib/redshift_extractor/copy.rb', line 3

def destination_schema
  @destination_schema
end

#destination_tableObject (readonly)

Returns the value of attribute destination_table.



3
4
5
# File 'lib/redshift_extractor/copy.rb', line 3

def destination_table
  @destination_table
end

Instance Method Details

#copy_sqlObject



13
14
15
16
17
# File 'lib/redshift_extractor/copy.rb', line 13

def copy_sql
  "copy #{destination_schema}.#{destination_table} from '#{data_source}'"\
  " credentials '#{credentials}'"\
  " manifest dateformat 'auto' timeformat 'auto' blanksasnull emptyasnull escape gzip removequotes delimiter '|';"
end

#credentialsObject



19
20
21
# File 'lib/redshift_extractor/copy.rb', line 19

def credentials
  "aws_access_key_id=#{aws_access_key_id};aws_secret_access_key=#{aws_secret_access_key}"
end