Class: Charrington::AlterRedshiftTable
- Inherits:
-
Object
- Object
- Charrington::AlterRedshiftTable
- Includes:
- LogStash::Util::Loggable, Service
- Defined in:
- lib/logstash/outputs/charrington/alter_redshift_table.rb
Overview
This service will add columns to an existing table dynamically based on finding new keys in the JSON structure. This is potentially called from Insert when an insert fails.
Constant Summary collapse
- Error =
Class.new(StandardError)
- AlterFailed =
Class.new(Error)
Instance Attribute Summary collapse
-
#column_types ⇒ Object
Returns the value of attribute column_types.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(connection, event, schema, table_name, columns) ⇒ AlterRedshiftTable
constructor
A new instance of AlterRedshiftTable.
Methods included from Service
Constructor Details
#initialize(connection, event, schema, table_name, columns) ⇒ AlterRedshiftTable
Returns a new instance of AlterRedshiftTable.
17 18 19 20 21 22 23 24 |
# File 'lib/logstash/outputs/charrington/alter_redshift_table.rb', line 17 def initialize(connection, event, schema, table_name, columns) @connection = connection @event = event.to_hash @schema = schema @table_name = table_name @columns = columns @column_types = [] end |
Instance Attribute Details
#column_types ⇒ Object
Returns the value of attribute column_types.
12 13 14 |
# File 'lib/logstash/outputs/charrington/alter_redshift_table.rb', line 12 def column_types @column_types end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
11 12 13 |
# File 'lib/logstash/outputs/charrington/alter_redshift_table.rb', line 11 def columns @columns end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
11 12 13 |
# File 'lib/logstash/outputs/charrington/alter_redshift_table.rb', line 11 def connection @connection end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
11 12 13 |
# File 'lib/logstash/outputs/charrington/alter_redshift_table.rb', line 11 def event @event end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
11 12 13 |
# File 'lib/logstash/outputs/charrington/alter_redshift_table.rb', line 11 def schema @schema end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
11 12 13 |
# File 'lib/logstash/outputs/charrington/alter_redshift_table.rb', line 11 def table_name @table_name end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/logstash/outputs/charrington/alter_redshift_table.rb', line 26 def call set_column_types alter_table true rescue StandardError => e raise AlterFailed, e. ensure @column_types.clear if @column_types.is_a? Array end |