Class: RedshiftExtractor::Unload
- Inherits:
-
Object
- Object
- RedshiftExtractor::Unload
- Defined in:
- lib/redshift_extractor/unload.rb
Instance Attribute Summary collapse
-
#aws_access_key_id ⇒ Object
readonly
Returns the value of attribute aws_access_key_id.
-
#aws_secret_access_key ⇒ Object
readonly
Returns the value of attribute aws_secret_access_key.
-
#s3_destination ⇒ Object
readonly
Returns the value of attribute s3_destination.
-
#select_sql ⇒ Object
readonly
Returns the value of attribute select_sql.
Instance Method Summary collapse
- #credentials ⇒ Object
- #escaped_extract_sql ⇒ Object
-
#initialize(args) ⇒ Unload
constructor
A new instance of Unload.
- #unload_sql ⇒ Object
Constructor Details
#initialize(args) ⇒ Unload
Returns a new instance of Unload.
5 6 7 8 9 10 |
# File 'lib/redshift_extractor/unload.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) @s3_destination = args.fetch(:s3_destination) @select_sql = args.fetch(:select_sql) end |
Instance Attribute Details
#aws_access_key_id ⇒ Object (readonly)
Returns the value of attribute aws_access_key_id.
3 4 5 |
# File 'lib/redshift_extractor/unload.rb', line 3 def aws_access_key_id @aws_access_key_id end |
#aws_secret_access_key ⇒ Object (readonly)
Returns the value of attribute aws_secret_access_key.
3 4 5 |
# File 'lib/redshift_extractor/unload.rb', line 3 def aws_secret_access_key @aws_secret_access_key end |
#s3_destination ⇒ Object (readonly)
Returns the value of attribute s3_destination.
3 4 5 |
# File 'lib/redshift_extractor/unload.rb', line 3 def s3_destination @s3_destination end |
#select_sql ⇒ Object (readonly)
Returns the value of attribute select_sql.
3 4 5 |
# File 'lib/redshift_extractor/unload.rb', line 3 def select_sql @select_sql end |
Instance Method Details
#credentials ⇒ Object
21 22 23 |
# File 'lib/redshift_extractor/unload.rb', line 21 def credentials "aws_access_key_id=#{aws_access_key_id};aws_secret_access_key=#{aws_secret_access_key}" end |
#escaped_extract_sql ⇒ Object
17 18 19 |
# File 'lib/redshift_extractor/unload.rb', line 17 def escaped_extract_sql select_sql.gsub("'", "\\\\'") end |
#unload_sql ⇒ Object
12 13 14 15 |
# File 'lib/redshift_extractor/unload.rb', line 12 def unload_sql "UNLOAD('#{escaped_extract_sql}') to '#{s3_destination}'"\ " CREDENTIALS '#{credentials}' MANIFEST GZIP ADDQUOTES ESCAPE;" end |