balinterdi-activewarehouse-etl 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/.gitignore +4 -0
  2. data/0.9-UPGRADE +6 -0
  3. data/CHANGELOG +198 -0
  4. data/HOW_TO_RELEASE +4 -0
  5. data/LICENSE +7 -0
  6. data/README +85 -0
  7. data/Rakefile +169 -0
  8. data/TODO +28 -0
  9. data/VERSION +1 -0
  10. data/active_support_logger.patch +78 -0
  11. data/balinterdi-activewarehouse-etl.gemspec +221 -0
  12. data/bin/etl +28 -0
  13. data/bin/etl.cmd +8 -0
  14. data/examples/database.example.yml +16 -0
  15. data/lib/etl.rb +78 -0
  16. data/lib/etl/batch.rb +2 -0
  17. data/lib/etl/batch/batch.rb +111 -0
  18. data/lib/etl/batch/directives.rb +55 -0
  19. data/lib/etl/builder.rb +2 -0
  20. data/lib/etl/builder/date_dimension_builder.rb +96 -0
  21. data/lib/etl/builder/time_dimension_builder.rb +31 -0
  22. data/lib/etl/commands/etl.rb +89 -0
  23. data/lib/etl/control.rb +3 -0
  24. data/lib/etl/control/control.rb +405 -0
  25. data/lib/etl/control/destination.rb +420 -0
  26. data/lib/etl/control/destination/database_destination.rb +95 -0
  27. data/lib/etl/control/destination/file_destination.rb +124 -0
  28. data/lib/etl/control/source.rb +109 -0
  29. data/lib/etl/control/source/database_source.rb +220 -0
  30. data/lib/etl/control/source/enumerable_source.rb +11 -0
  31. data/lib/etl/control/source/file_source.rb +90 -0
  32. data/lib/etl/control/source/model_source.rb +39 -0
  33. data/lib/etl/core_ext.rb +1 -0
  34. data/lib/etl/core_ext/time.rb +5 -0
  35. data/lib/etl/core_ext/time/calculations.rb +42 -0
  36. data/lib/etl/engine.rb +556 -0
  37. data/lib/etl/execution.rb +20 -0
  38. data/lib/etl/execution/base.rb +9 -0
  39. data/lib/etl/execution/batch.rb +8 -0
  40. data/lib/etl/execution/job.rb +8 -0
  41. data/lib/etl/execution/migration.rb +85 -0
  42. data/lib/etl/generator.rb +2 -0
  43. data/lib/etl/generator/generator.rb +20 -0
  44. data/lib/etl/generator/surrogate_key_generator.rb +39 -0
  45. data/lib/etl/http_tools.rb +139 -0
  46. data/lib/etl/parser.rb +11 -0
  47. data/lib/etl/parser/apache_combined_log_parser.rb +49 -0
  48. data/lib/etl/parser/delimited_parser.rb +75 -0
  49. data/lib/etl/parser/fixed_width_parser.rb +65 -0
  50. data/lib/etl/parser/parser.rb +41 -0
  51. data/lib/etl/parser/sax_parser.rb +218 -0
  52. data/lib/etl/parser/xml_parser.rb +65 -0
  53. data/lib/etl/processor.rb +11 -0
  54. data/lib/etl/processor/block_processor.rb +14 -0
  55. data/lib/etl/processor/bulk_import_processor.rb +81 -0
  56. data/lib/etl/processor/check_exist_processor.rb +80 -0
  57. data/lib/etl/processor/check_unique_processor.rb +35 -0
  58. data/lib/etl/processor/copy_field_processor.rb +26 -0
  59. data/lib/etl/processor/encode_processor.rb +55 -0
  60. data/lib/etl/processor/hierarchy_exploder_processor.rb +55 -0
  61. data/lib/etl/processor/print_row_processor.rb +12 -0
  62. data/lib/etl/processor/processor.rb +25 -0
  63. data/lib/etl/processor/rename_processor.rb +24 -0
  64. data/lib/etl/processor/require_non_blank_processor.rb +26 -0
  65. data/lib/etl/processor/row_processor.rb +17 -0
  66. data/lib/etl/processor/sequence_processor.rb +23 -0
  67. data/lib/etl/processor/surrogate_key_processor.rb +53 -0
  68. data/lib/etl/processor/truncate_processor.rb +35 -0
  69. data/lib/etl/row.rb +20 -0
  70. data/lib/etl/screen.rb +14 -0
  71. data/lib/etl/screen/row_count_screen.rb +20 -0
  72. data/lib/etl/transform.rb +2 -0
  73. data/lib/etl/transform/block_transform.rb +13 -0
  74. data/lib/etl/transform/date_to_string_transform.rb +20 -0
  75. data/lib/etl/transform/decode_transform.rb +51 -0
  76. data/lib/etl/transform/default_transform.rb +20 -0
  77. data/lib/etl/transform/foreign_key_lookup_transform.rb +151 -0
  78. data/lib/etl/transform/hierarchy_lookup_transform.rb +49 -0
  79. data/lib/etl/transform/ordinalize_transform.rb +12 -0
  80. data/lib/etl/transform/sha1_transform.rb +13 -0
  81. data/lib/etl/transform/string_to_date_transform.rb +16 -0
  82. data/lib/etl/transform/string_to_datetime_transform.rb +14 -0
  83. data/lib/etl/transform/string_to_time_transform.rb +11 -0
  84. data/lib/etl/transform/transform.rb +61 -0
  85. data/lib/etl/transform/trim_transform.rb +26 -0
  86. data/lib/etl/transform/type_transform.rb +35 -0
  87. data/lib/etl/util.rb +59 -0
  88. data/lib/etl/version.rb +9 -0
  89. data/test/.ignore +2 -0
  90. data/test/all.ebf +6 -0
  91. data/test/apache_combined_log.ctl +11 -0
  92. data/test/batch_test.rb +41 -0
  93. data/test/batch_with_error.ebf +6 -0
  94. data/test/batched1.ctl +0 -0
  95. data/test/batched2.ctl +0 -0
  96. data/test/block_processor.ctl +6 -0
  97. data/test/block_processor_error.ctl +1 -0
  98. data/test/block_processor_pre_post_process.ctl +4 -0
  99. data/test/block_processor_remove_rows.ctl +5 -0
  100. data/test/block_processor_test.rb +38 -0
  101. data/test/connection/native_mysql/connection.rb +9 -0
  102. data/test/connection/native_mysql/schema.sql +36 -0
  103. data/test/connection/postgresql/connection.rb +13 -0
  104. data/test/connection/postgresql/schema.sql +43 -0
  105. data/test/control_test.rb +43 -0
  106. data/test/data/apache_combined_log.txt +3 -0
  107. data/test/data/bulk_import.txt +3 -0
  108. data/test/data/bulk_import_with_empties.txt +3 -0
  109. data/test/data/decode.txt +3 -0
  110. data/test/data/delimited.txt +3 -0
  111. data/test/data/encode_source_latin1.txt +2 -0
  112. data/test/data/fixed_width.txt +3 -0
  113. data/test/data/multiple_delimited_1.txt +3 -0
  114. data/test/data/multiple_delimited_2.txt +3 -0
  115. data/test/data/people.txt +3 -0
  116. data/test/data/sax.xml +14 -0
  117. data/test/data/xml.xml +16 -0
  118. data/test/database.example.yml +18 -0
  119. data/test/database.mysql.yml +18 -0
  120. data/test/database.postgres.yml +18 -0
  121. data/test/database.yml +18 -0
  122. data/test/date_dimension_builder_test.rb +96 -0
  123. data/test/delimited.ctl +30 -0
  124. data/test/delimited_absolute.ctl +33 -0
  125. data/test/delimited_destination_db.ctl +25 -0
  126. data/test/delimited_with_bulk_load.ctl +34 -0
  127. data/test/destination_test.rb +171 -0
  128. data/test/directive_test.rb +23 -0
  129. data/test/encode_processor_test.rb +31 -0
  130. data/test/engine_test.rb +32 -0
  131. data/test/errors.ctl +24 -0
  132. data/test/etl_test.rb +42 -0
  133. data/test/fixed_width.ctl +35 -0
  134. data/test/generator_test.rb +14 -0
  135. data/test/inline_parser.ctl +17 -0
  136. data/test/mocks/mock_destination.rb +26 -0
  137. data/test/mocks/mock_source.rb +25 -0
  138. data/test/model_source.ctl +14 -0
  139. data/test/multiple_delimited.ctl +22 -0
  140. data/test/multiple_source_delimited.ctl +39 -0
  141. data/test/parser_test.rb +200 -0
  142. data/test/performance/delimited.ctl +30 -0
  143. data/test/processor_test.rb +38 -0
  144. data/test/row_processor_test.rb +17 -0
  145. data/test/sax.ctl +26 -0
  146. data/test/scd/1.txt +1 -0
  147. data/test/scd/2.txt +1 -0
  148. data/test/scd/3.txt +1 -0
  149. data/test/scd_test.rb +263 -0
  150. data/test/scd_test_type_1.ctl +43 -0
  151. data/test/scd_test_type_2.ctl +42 -0
  152. data/test/screen_test.rb +9 -0
  153. data/test/screen_test_error.ctl +3 -0
  154. data/test/screen_test_fatal.ctl +3 -0
  155. data/test/source_test.rb +139 -0
  156. data/test/test_helper.rb +33 -0
  157. data/test/transform_test.rb +101 -0
  158. data/test/xml.ctl +31 -0
  159. metadata +237 -0
@@ -0,0 +1,30 @@
1
+ # puts "executing delimited.ctl"
2
+
3
+ source :in, {
4
+ :file => 'delimited.txt',
5
+ :parser => :delimited
6
+ },
7
+ [
8
+ :first_name,
9
+ :last_name,
10
+ :ssn,
11
+ {
12
+ :name => :age,
13
+ :type => :integer
14
+ },
15
+ :sex
16
+ ]
17
+
18
+ transform :ssn, :sha1
19
+ transform(:ssn){ |v| v[0,24] }
20
+ transform :sex, :decode, {:decode_table_path => 'delimited_decode.txt'}
21
+
22
+ destination :out, {
23
+ :file => 'delimited.out.txt'
24
+ },
25
+ {
26
+ :order => [:first_name, :last_name, :name, :ssn, :age, :sex],
27
+ :virtual => {
28
+ :name => Proc.new { |row| "#{row[:first_name]} #{row[:last_name]}" }
29
+ }
30
+ }
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class Person < ActiveRecord::Base
4
+ end
5
+
6
+ # Test pre- and post-processors
7
+ class ProcessorTest < Test::Unit::TestCase
8
+ # Test bulk import functionality
9
+
10
+ context "the bulk import processor" do
11
+ should "should import successfully" do
12
+ assert_nothing_raised { do_bulk_import }
13
+ assert_equal 3, Person.count
14
+ end
15
+ end
16
+
17
+ def test_bulk_import_with_empties
18
+ assert_raise(ActiveRecord::StatementInvalid) { do_bulk_import('bulk_import_with_empties.txt') }
19
+ end
20
+
21
+ def test_truncate
22
+ # TODO: implement test
23
+ end
24
+
25
+ private
26
+
27
+ def do_bulk_import(file = 'bulk_import.txt')
28
+ control = ETL::Control::Control.new(File.join(File.dirname(__FILE__), 'delimited.ctl'))
29
+ configuration = {
30
+ :file => "data/#{file}",
31
+ :truncate => true,
32
+ :target => :data_warehouse,
33
+ :table => 'people'
34
+ }
35
+ processor = ETL::Processor::BulkImportProcessor.new(control, configuration)
36
+ processor.process
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ # Test row processors
4
+ class RowProcessorTest < Test::Unit::TestCase
5
+ def test_copy_field_processor
6
+
7
+ end
8
+ def test_hierarchy_exploder_processor
9
+
10
+ end
11
+ def test_rename_processor
12
+
13
+ end
14
+ def test_sequence_processor
15
+
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # puts "executing fixed_width.ctl"
2
+
3
+ source :in, {
4
+ :file => 'data/sax.xml',
5
+ :parser => :sax
6
+ },
7
+ {
8
+ :write_trigger => 'people/person',
9
+ :fields => {
10
+ :first_name => 'people/person/first_name',
11
+ :last_name => 'people/person/last_name',
12
+ :ssn => 'people/person/social_security_number',
13
+ :age => 'people/person[age]'
14
+ }
15
+ }
16
+
17
+ transform :ssn, :sha1
18
+ transform(:ssn){ |v| v[0,24] }
19
+ transform :age, :type, {:type => :number}
20
+
21
+ destination :out, {
22
+ :file => 'output/sax.out.txt'
23
+ },
24
+ {
25
+ :order => [:first_name, :last_name, :ssn, :age]
26
+ }
@@ -0,0 +1 @@
1
+ Bob,Smith,200 South Drive,Boston,MA,32123
@@ -0,0 +1 @@
1
+ Bob,Smith,1010 SW 23rd St,Los Angeles,CA,90392
@@ -0,0 +1 @@
1
+ Bob,Smith,280 Pine Street,Los Angeles,CA,90392
@@ -0,0 +1,263 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ScdTest < Test::Unit::TestCase
4
+ context "when working with a slowly changing dimension" do
5
+ setup do
6
+ @connection = ETL::Engine.connection(:data_warehouse)
7
+ @connection.delete("DELETE FROM person_dimension")
8
+ @end_of_time = DateTime.parse('9999-12-31 00:00:00')
9
+ end
10
+ context "of type 1" do
11
+ context "on run 1" do
12
+ setup do
13
+ do_type_1_run(1)
14
+ end
15
+ should "insert record" do
16
+ assert_equal 1, count_bobs
17
+ end
18
+ should "set the original address" do
19
+ assert_boston_address(find_bobs.first)
20
+ end
21
+ should "set the original id" do
22
+ assert_equal 1, find_bobs.first.id
23
+ end
24
+ should "skip the load if there is no change" do
25
+ do_type_1_run(1)
26
+ lines = lines_for('scd_test_type_1.txt')
27
+ assert lines.empty?, "scheduled load expected to be empty, was #{lines.size} records"
28
+ end
29
+ end
30
+ context "on run 2" do
31
+ setup do
32
+ do_type_1_run(1)
33
+ do_type_1_run(2)
34
+ end
35
+ should "delete the old record" do
36
+ assert_equal 1, count_bobs, "new record created, but old not deleted: #{find_bobs.inspect}"
37
+ end
38
+ should "update the address" do
39
+ assert_los_angeles_address(find_bobs.last)
40
+ end
41
+ should "keep id" do
42
+ assert_equal 1, find_bobs.first.id
43
+ end
44
+ should "only change once even if run again" do
45
+ do_type_1_run(2)
46
+ assert_equal 1, count_bobs
47
+ lines = lines_for('scd_test_type_1.txt')
48
+ assert lines.empty?, "scheduled load expected to be empty, was #{lines.size} records"
49
+ end
50
+ should "revert address on new record" do
51
+ do_type_1_run(1)
52
+ assert_boston_address(find_bobs.first)
53
+ end
54
+ should "keep record on revert" do
55
+ do_type_1_run(1)
56
+ assert_equal 1, count_bobs
57
+ end
58
+ end
59
+ end
60
+ context "of type 2" do
61
+ context "on run 1" do
62
+ setup do
63
+ do_type_2_run(1)
64
+ end
65
+ should "insert record" do
66
+ assert_equal 1, count_bobs
67
+ end
68
+ should "set the original record" do
69
+ assert_boston_address(find_bobs.first)
70
+ end
71
+ should "set the original id" do
72
+ assert_equal 1, find_bobs.first.id
73
+ end
74
+ should "set the effective date" do
75
+ # TODO: This is a test bug - if the tests don't run at the correct
76
+ # time, this timestamp may not match the timestamp used during the
77
+ # creation of the SCD row
78
+ assert_equal current_datetime, find_bobs.first.effective_date,
79
+ "failure might be a test bug - see test notes"
80
+ end
81
+ should "set the end date" do
82
+ assert_equal @end_of_time, find_bobs.first.end_date
83
+ end
84
+ should "set the latest version flag" do
85
+ assert find_bobs.first.latest_version?
86
+ end
87
+ should "skip the load if there is no change" do
88
+ do_type_2_run(1)
89
+ lines = lines_for('scd_test_type_2.txt')
90
+ assert lines.empty?, "scheduled load expected to be empty, was #{lines.size} records"
91
+ end
92
+
93
+ end
94
+ context "on run 2" do
95
+ setup do
96
+ do_type_2_run(1)
97
+ do_type_2_run(2)
98
+ end
99
+ should "insert new record" do
100
+ assert_equal 2, count_bobs
101
+ end
102
+ should "keep the primary key of the original version" do
103
+ assert_not_nil find_bobs.detect { |bob| 1 == bob.id }
104
+ end
105
+ should "increment the primary key for the new version" do
106
+ assert_not_nil find_bobs.detect { |bob| 2 == bob.id }
107
+ end
108
+ should "expire the old record" do
109
+ original_bob = find_bobs.detect { |bob| 1 == bob.id }
110
+ new_bob = find_bobs.detect { |bob| 2 == bob.id }
111
+ assert_equal new_bob.effective_date, original_bob.end_date
112
+ end
113
+ should "keep the address for the expired record" do
114
+ assert_boston_address(find_bobs.detect { |bob| 1 == bob.id })
115
+ end
116
+ should "update the address on the new record" do
117
+ assert_los_angeles_address(find_bobs.detect { |bob| 2 == bob.id })
118
+ end
119
+ should "activate the new record" do
120
+ # TODO: This is a test bug - if the tests don't run at the correct
121
+ # time, this timestamp may not match the timestamp used during the
122
+ # creation of the SCD row
123
+ assert_equal current_datetime, find_bobs.detect { |bob| 2 == bob.id }.effective_date,
124
+ "failure might be a test bug - see test notes"
125
+ end
126
+ should "set the end date for the new record" do
127
+ assert_equal @end_of_time, find_bobs.detect { |bob| 2 == bob.id }.end_date
128
+ end
129
+ should "shift the latest version" do
130
+ original_bob = find_bobs.detect { |bob| 1 == bob.id }
131
+ new_bob = find_bobs.detect { |bob| 2 == bob.id }
132
+ assert !original_bob.latest_version?
133
+ assert new_bob.latest_version?
134
+ end
135
+ should "only execute a change once" do
136
+ do_type_2_run(2)
137
+ assert_equal 2, count_bobs
138
+ lines = lines_for('scd_test_type_2.txt')
139
+ assert lines.empty?, "scheduled load expected to be empty, was #{lines.size} records"
140
+ end
141
+ should "insert new records on revert" do
142
+ do_type_2_run(1)
143
+ assert_equal 3, count_bobs
144
+ end
145
+ should "update address on new record on revert" do
146
+ do_type_2_run(1)
147
+ assert_boston_address(find_bobs.detect { |bob| 3 == bob.id })
148
+ end
149
+ should "only delete one row on an scd change" do
150
+ # Two records right now
151
+ assert_equal 2, count_bobs
152
+ do_type_2_run(1) # put third version in (same as first version, but that's irrelevant)
153
+ # was failing because first and second versions were being deleted.
154
+ assert_equal 3, count_bobs
155
+ end
156
+ end
157
+ context "on non sdc fields that change" do
158
+ setup do
159
+ do_type_2_run_with_only_city_state_zip_scd(1)
160
+ do_type_2_run_with_only_city_state_zip_scd(2)
161
+ end
162
+ should "not create an extra record" do
163
+ do_type_2_run_with_only_city_state_zip_scd(3)
164
+ assert_equal 2, count_bobs
165
+ end
166
+ should "keep id" do
167
+ do_type_2_run_with_only_city_state_zip_scd(3)
168
+ assert_not_nil find_bobs.detect { |bob| 2 == bob.id }
169
+ end
170
+ should "keep dates" do
171
+ old_bob = find_bobs.detect { |bob| 2 == bob.id }
172
+ do_type_2_run_with_only_city_state_zip_scd(3)
173
+ new_bob = find_bobs.detect { |bob| 2 == bob.id }
174
+ assert_equal old_bob.end_date, new_bob.end_date
175
+ assert_equal old_bob.effective_date, new_bob.effective_date
176
+ end
177
+ should "keep the latest version flag" do
178
+ do_type_2_run_with_only_city_state_zip_scd(3)
179
+ assert find_bobs.detect { |bob| 2 == bob.id }.latest_version?
180
+ end
181
+ should "treat non scd fields like type 1 fields" do
182
+ do_type_2_run_with_only_city_state_zip_scd(3)
183
+ assert_los_angeles_address(find_bobs.detect { |bob| 2 == bob.id }, "280 Pine Street")
184
+ end
185
+ should "skip load when there is no change" do
186
+ do_type_2_run_with_only_city_state_zip_scd(2)
187
+ lines = lines_for('scd_test_type_2.txt')
188
+ assert lines.empty?, "scheduled load expected to be empty, was #{lines.size} records"
189
+ end
190
+ end
191
+ end
192
+ end
193
+
194
+ def do_type_2_run(run_num)
195
+ ENV['run_number'] = run_num.to_s
196
+ assert_nothing_raised do
197
+ run_ctl_file("scd_test_type_2.ctl")
198
+ end
199
+ end
200
+
201
+ def do_type_2_run_with_only_city_state_zip_scd(run_num)
202
+ ENV['type_2_scd_fields'] = Marshal.dump([:city, :state, :zip_code])
203
+ do_type_2_run(run_num)
204
+ end
205
+
206
+ def do_type_1_run(run_num)
207
+ ENV['run_number'] = run_num.to_s
208
+ assert_nothing_raised do
209
+ run_ctl_file("scd_test_type_1.ctl")
210
+ end
211
+ end
212
+
213
+ def lines_for(file)
214
+ File.readlines(File.dirname(__FILE__) + "/output/#{file}")
215
+ end
216
+
217
+ def run_ctl_file(file)
218
+ ETL::Engine.process(File.dirname(__FILE__) + "/#{file}")
219
+ end
220
+
221
+ def count_bobs
222
+ @connection.select_value(
223
+ "SELECT count(*) FROM person_dimension WHERE first_name = 'Bob' and last_name = 'Smith'").to_i
224
+ end
225
+
226
+ def find_bobs
227
+ bobs = @connection.select_all(
228
+ "SELECT * FROM person_dimension WHERE first_name = 'Bob' and last_name = 'Smith'")
229
+ bobs.each do |bob|
230
+ def bob.id
231
+ self["id"].to_i
232
+ end
233
+ def bob.effective_date
234
+ DateTime.parse(self["effective_date"])
235
+ end
236
+ def bob.end_date
237
+ DateTime.parse(self["end_date"])
238
+ end
239
+ def bob.latest_version?
240
+ ActiveRecord::ConnectionAdapters::Column.value_to_boolean(self["latest_version"])
241
+ end
242
+ end
243
+ bobs
244
+ end
245
+
246
+ def current_datetime
247
+ DateTime.parse(Time.now.to_s(:db))
248
+ end
249
+
250
+ def assert_boston_address(bob, street = "200 South Drive")
251
+ assert_equal street, bob['address'], bob.inspect
252
+ assert_equal "Boston", bob['city'], bob.inspect
253
+ assert_equal "MA", bob['state'], bob.inspect
254
+ assert_equal "32123", bob['zip_code'], bob.inspect
255
+ end
256
+
257
+ def assert_los_angeles_address(bob, street = "1010 SW 23rd St")
258
+ assert_equal street, bob['address'], bob.inspect
259
+ assert_equal "Los Angeles", bob['city'], bob.inspect
260
+ assert_equal "CA", bob['state'], bob.inspect
261
+ assert_equal "90392", bob['zip_code'], bob.inspect
262
+ end
263
+ end
@@ -0,0 +1,43 @@
1
+ source :in, {
2
+ :file => "scd/#{ENV['run_number']}.txt",
3
+ :parser => :delimited
4
+ },
5
+ [
6
+ :first_name,
7
+ :last_name,
8
+ :address,
9
+ :city,
10
+ :state,
11
+ :zip_code
12
+ ]
13
+
14
+ # NOTE: These are not usually required for a type 1 SCD dimension, but since
15
+ # we're sharing this table with the type 2 tests, they're necessary.
16
+ transform :effective_date, :default, :default_value => Time.now.to_s(:db)
17
+ transform :end_date, :default, :default_value => '9999-12-31 00:00:00'
18
+ transform :latest_version, :default, :default_value => true
19
+
20
+ destination :out, {
21
+ :file => 'output/scd_test_type_1.txt',
22
+ :natural_key => [:first_name, :last_name],
23
+ :scd => {
24
+ :type => 1,
25
+ :dimension_target => :data_warehouse,
26
+ :dimension_table => 'person_dimension'
27
+ },
28
+ :scd_fields => [:address, :city, :state, :zip_code]
29
+ },
30
+ {
31
+ :order => [
32
+ :id, :first_name, :last_name, :address, :city, :state, :zip_code, :effective_date, :end_date, :latest_version
33
+ ],
34
+ :virtual => {
35
+ :id => ETL::Generator::SurrogateKeyGenerator.new(:target => :data_warehouse, :table => 'person_dimension')
36
+ }
37
+ }
38
+
39
+ post_process :bulk_import, {
40
+ :file => 'output/scd_test_type_1.txt',
41
+ :target => :data_warehouse,
42
+ :table => 'person_dimension'
43
+ }
@@ -0,0 +1,42 @@
1
+ source :in, {
2
+ :file => "scd/#{ENV['run_number']}.txt",
3
+ :parser => :delimited
4
+ },
5
+ [
6
+ :first_name,
7
+ :last_name,
8
+ :address,
9
+ :city,
10
+ :state,
11
+ :zip_code
12
+ ]
13
+
14
+
15
+
16
+
17
+
18
+
19
+ destination :out, {
20
+ :file => 'output/scd_test_type_2.txt',
21
+ :natural_key => [:first_name, :last_name],
22
+ :scd => {
23
+ :type => 2,
24
+ :dimension_target => :data_warehouse,
25
+ :dimension_table => 'person_dimension'
26
+ },
27
+ :scd_fields => ENV['type_2_scd_fields'] ? Marshal.load(ENV['type_2_scd_fields']) : [:address, :city, :state, :zip_code]
28
+ },
29
+ {
30
+ :order => [
31
+ :id, :first_name, :last_name, :address, :city, :state, :zip_code, :effective_date, :end_date, :latest_version
32
+ ],
33
+ :virtual => {
34
+ :id => ETL::Generator::SurrogateKeyGenerator.new(:target => :data_warehouse, :table => 'person_dimension')
35
+ }
36
+ }
37
+
38
+ post_process :bulk_import, {
39
+ :file => 'output/scd_test_type_2.txt',
40
+ :target => :data_warehouse,
41
+ :table => 'person_dimension'
42
+ }