Class: Chicago::ETL::SchemaSinksAndTransformationsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/chicago/etl/schema_sinks_and_transformations_builder.rb

Overview

Provides DSL methods for specifying the pipeline in an ETL stage.

Clients will not normally instantiate this themselves but use it in the context of defining an ETL stage.

Defined Under Namespace

Classes: KeyMapping

Constant Summary collapse

TRANSFORMATION_ORDER =

The ordering of inbuilt transformation and screening steps.

[:before_screens,
 :screens,
 :after_screens,
 :before_keys,
 :keys,
 :after_keys,
 :before_final,
 :final,
 :after_final
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(db, schema_table) ⇒ SchemaSinksAndTransformationsBuilder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SchemaSinksAndTransformationsBuilder.



25
26
27
28
29
# File 'lib/chicago/etl/schema_sinks_and_transformations_builder.rb', line 25

def initialize(db, schema_table)
  @db = db
  @schema_table = schema_table
  @sink_factory = SchemaTableSinkFactory.new(@db, @schema_table)
end

Instance Method Details

#build(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/chicago/etl/schema_sinks_and_transformations_builder.rb', line 32

def build(&block)
  @load_separately = []
  @key_mappings    = []
  @transformations = {}
  TRANSFORMATION_ORDER.each {|k| @transformations[k] = [] }
  @ignore_present_rows = false

  instance_eval &block

  add_screens
  add_key_transforms
  add_final_transforms
  sinks_and_transformations = create_sinks_and_transformations
  register_additional_sinks(sinks_and_transformations)
  sinks_and_transformations
end