Class: Chicago::ETL::Transformations::HashColumns
Overview
Adds a hash of the specified columns as a field in the row.
Instance Method Summary
collapse
added_fields, adds_fields, #applies_to_stream?, #downstream_fields, #flush, #initialize, #output_streams, #process, removed_fields, #removed_fields, removes_fields, #required_options, required_options, requires_options, #upstream_fields
Instance Method Details
#added_fields ⇒ Object
114
115
116
|
# File 'lib/chicago/etl/transformations.rb', line 114
def added_fields
[output_field]
end
|
#hash_columns ⇒ Object
122
123
124
|
# File 'lib/chicago/etl/transformations.rb', line 122
def hash_columns
@options[:columns]
end
|
#output_field ⇒ Object
118
119
120
|
# File 'lib/chicago/etl/transformations.rb', line 118
def output_field
@options[:output_field] || :hash
end
|
#process_row(row) ⇒ Object
109
110
111
112
|
# File 'lib/chicago/etl/transformations.rb', line 109
def process_row(row)
str = hash_columns.map {|c| row[c].to_s }.join
row.put(output_field, Digest::MD5.hexdigest(str).upcase)
end
|