Class: Chicago::ETL::Transformations::DimensionKeyMapping

Inherits:
Chicago::ETL::Transformation show all
Defined in:
lib/chicago/etl/transformations.rb

Overview

Removes a field from the row, and creates a row on a designated key stream

Instance Method Summary collapse

Methods inherited from Chicago::ETL::Transformation

#added_fields, added_fields, adds_fields, #applies_to_stream?, #downstream_fields, #flush, #initialize, #process, removed_fields, removes_fields, #required_options, required_options, requires_options, #upstream_fields

Constructor Details

This class inherits a constructor from Chicago::ETL::Transformation

Instance Method Details

#key_tableObject



100
101
102
# File 'lib/chicago/etl/transformations.rb', line 100

def key_table
  @options[:key_table]
end

#original_keyObject



96
97
98
# File 'lib/chicago/etl/transformations.rb', line 96

def original_key
  @options[:original_key]
end

#output_streamsObject



83
84
85
# File 'lib/chicago/etl/transformations.rb', line 83

def output_streams
  [:default, key_table]
end

#process_row(row) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/chicago/etl/transformations.rb', line 87

def process_row(row)
  key_row = {
    :original_id => row.delete(original_key),
    :dimension_id => row[:id]
  }
  assign_stream(key_row, key_table)
  [row, key_row]
end

#removed_fieldsObject



79
80
81
# File 'lib/chicago/etl/transformations.rb', line 79

def removed_fields
  [original_key]
end