Class: RedshiftConnector::Importer::InsertDelta
- Inherits:
-
Object
- Object
- RedshiftConnector::Importer::InsertDelta
- Defined in:
- lib/redshift-connector/importer/insert_delta.rb
Instance Method Summary collapse
- #delete_rows(cond_expr) ⇒ Object
- #execute ⇒ Object
- #import ⇒ Object
-
#initialize(dao:, bundle:, columns:, delete_cond:, logger: RedshiftConnector.logger) ⇒ InsertDelta
constructor
A new instance of InsertDelta.
Constructor Details
#initialize(dao:, bundle:, columns:, delete_cond:, logger: RedshiftConnector.logger) ⇒ InsertDelta
6 7 8 9 10 11 12 |
# File 'lib/redshift-connector/importer/insert_delta.rb', line 6 def initialize(dao:, bundle:, columns:, delete_cond:, logger: RedshiftConnector.logger) @dao = dao @bundle = bundle @columns = columns @delete_cond = delete_cond @logger = logger end |
Instance Method Details
#delete_rows(cond_expr) ⇒ Object
19 20 21 22 23 |
# File 'lib/redshift-connector/importer/insert_delta.rb', line 19 def delete_rows(cond_expr) @logger.info "DELETE #{@dao.table_name} where (#{cond_expr})" @dao.connection.execute("delete from #{@dao.table_name} where #{cond_expr}") @logger.info "deleted." end |
#execute ⇒ Object
14 15 16 17 |
# File 'lib/redshift-connector/importer/insert_delta.rb', line 14 def execute delete_rows(@delete_cond) import end |
#import ⇒ Object
25 26 27 28 29 30 |
# File 'lib/redshift-connector/importer/insert_delta.rb', line 25 def import @logger.info "IMPORT #{@bundle.url}* -> #{@dao.table_name} (#{@columns.join(', ')})" @bundle.each_batch do |rows| @dao.import(@columns, rows) end end |