Class: RedshiftConnector::UnloadQuery
- Inherits:
-
Object
- Object
- RedshiftConnector::UnloadQuery
- Defined in:
- lib/redshift-connector/query.rb
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
- #escape_query(query) ⇒ Object
-
#initialize(query:, bundle:) ⇒ UnloadQuery
constructor
A new instance of UnloadQuery.
- #table_spec ⇒ Object
- #to_sql ⇒ Object
Constructor Details
#initialize(query:, bundle:) ⇒ UnloadQuery
Returns a new instance of UnloadQuery.
51 52 53 54 |
# File 'lib/redshift-connector/query.rb', line 51 def initialize(query:, bundle:) @query = query @bundle = bundle end |
Class Method Details
.wrap(query:, bundle:) ⇒ Object
47 48 49 |
# File 'lib/redshift-connector/query.rb', line 47 def UnloadQuery.wrap(query:, bundle:) new(query: ArbitraryQuery.new(query), bundle: bundle) end |
Instance Method Details
#description ⇒ Object
60 61 62 |
# File 'lib/redshift-connector/query.rb', line 60 def description @query.description end |
#escape_query(query) ⇒ Object
75 76 77 |
# File 'lib/redshift-connector/query.rb', line 75 def escape_query(query) query.gsub("'", "\\\\'") end |
#table_spec ⇒ Object
56 57 58 |
# File 'lib/redshift-connector/query.rb', line 56 def table_spec @query.table_spec end |
#to_sql ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/redshift-connector/query.rb', line 64 def to_sql " unload ('\#{escape_query(@query.to_sql)}')\n to '\#{@bundle.url}'\n credentials '\#{@bundle.credential_string}'\n gzip\n allowoverwrite\n delimiter ',' escape addquotes\n EndSQL\nend\n".gsub(/^\s+/, '') |