Core Concepts
At the heart of etl4s is a single abstraction:
A Node is just a lazy, typed functionIn => Out
that can be chained into pipelines using ~>
. That's it.
Node types¶
For clarity and intent, etl4s provides 4 nodes aliases:
type Extract[-In, +Out] = Node[In, Out]
type Transform[-In, +Out] = Node[In, Out]
type Load[-In, +Out] = Node[In, Out]
type Pipeline[-In, +Out] = Node[In, Out]
Quick examples¶
import etl4s._
// A basic extract node
val extract: Extract[Unit, String] = Extract("hello")
// A transform node from String to Int
val getStringLen = Transform[String, Int](_.length)
println(extract(())) // hello
println(getStringLen("hi")) // 2
Building pipelines¶
Compose nodes with ~>
:
val E = Extract("hello")
val T = Transform[String, Int](_.length)
val L = Load[Int, String](n => s"Length: $n")
val pipeline = E ~> T ~> L
Executing pipelines¶
1) Call them like functions¶
All pipelines are just values of type In => Out
, so you can run them like this:
2) Use .unsafeRun(...)
¶
To run with error surfacing
3) Use .safeRun(...)
¶
To catch exceptions:
4) Run and measure time¶
Run your pipeline: