Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Background
Workflow DSL (#310) covers job-to-job relationships only. The data flow inside a single Spark job needs its own abstraction. This task implements the Step model for Spark — Source / Flow / Merge / Split / Sink composition, both as a Scala DSL and as inline YAML via StepsRunnerJob. Other job kinds (e.g., bash) are out of scope.
Task
-
Stepsealed trait:Source(0→1) /Flow(1→1) /Merge(N→1) /Split(1→M) /Sink(1→0) - Type-state
PlanDSL:~>,+,.as,fanOut, port selector for Split - Executor: memoization,
fanOutcache, Split port memo, plan-time validation -
StepsRunnerJobfor inline YAML chains - Built-ins:
FileSource,SampleSource,SqlMerge,CacheFlow,FileSink,ShowSink - Tests
Done When
- A Spark job can be expressed in Scala via
Source ~> Flow ~> Sinkwith type-state safety (a chain without a Sink fails to compile). - A Spark job can be expressed in YAML via
kind: spark,mainClass: StepsRunnerJob, and an inlinesteps:list. - Memoization is verifiable: a shared upstream feeding multiple sinks runs only once within a run.
fanOutruns each branch against a cached upstream and unpersists after.- A
Splitstep produces M named outputs from one input, addressable viaas: {port: label}(YAML) orforked("port")(Scala); the split body runs once per execution. - All listed plan-time validations reject invalid graphs before execution.
Notes
Step signatures
| Kind | Signature | In | Out |
|---|---|---|---|
| Source | read(): DataFrame |
0 | 1 |
| Flow | apply(in: DataFrame): DataFrame |
1 | 1 |
| Merge | apply(inputs: Seq[(label, DataFrame)]): DataFrame |
N | 1 |
| Split | split(in: DataFrame): Map[String, DataFrame] |
1 | M |
| Sink | write(df: DataFrame): Unit |
1 | 0 |
A Merge receives labeled inputs, so consumers like SqlMerge use each label as the temp view name. The default label for a single-input chain is "_0". A Split declares output ports (string keys) addressed by downstream via as: {port: label} or forked("port").
Scala DSL
class JoinJob extends Job[JoinCfg] {
override def plan(cfg: JoinCfg): Plan.Closed = {
val users = FileSource("users.parquet").as("u")
val events = FileSource("events.parquet").as("e")
(users + events) ~>
SqlMerge("SELECT u.name, e.kind FROM u JOIN e ON u.id = e.user_id") ~>
ShowSink()
}
}| Operator | Meaning |
|---|---|
~> |
pipe |
+ |
combine for multi-input Merge |
.as("name") |
label this output (also the SQL view name) |
fanOut(...) |
broadcast: a shared upstream feeds multiple Sink branches with the same data |
forked("port") |
select an output port of a Split |
YAML inline — StepsRunnerJob
jobs:
pi:
kind: spark
artifact: "com.kakao.actionbase:pipeline:0.x"
mainClass: StepsRunnerJob
args:
steps:
- step: SampleSource
args: { n: 1000000, columns: [x, y] }
- step: SqlMerge
args:
query: "SELECT 4.0*SUM(CASE WHEN x*x+y*y<=1 THEN 1 ELSE 0 END)/COUNT(*) AS pi FROM _0"
- step: ShowSink| Field | Meaning |
|---|---|
step |
class name (short / sub-package / FQN) |
args |
bound to case class fields |
as |
output label. String for Source/Flow/Merge; map {port: label} for Split |
inputs |
upstream labels; empty → previous step (linear chain, label "_0") |
Related: #310 (workflow DSL), #311 (initial PR — closed in favor of split).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
[-]ADR: Step model for Spark jobs[/-][+]Add Step DSL (Source/Transform/Sink) for Spark jobs[/+]em3s commentedon May 13, 2026
Spec revised: Transform → Flow / Merge / Split
After implementing the initial Source/Transform/Sink in #314 and dogfooding it on a real ALS i2i workload in #325, two limitations surfaced:
Resolution: split
Transforminto Flow (1→1) and Merge (N→1), add Split (1→M) as a sibling. Source/Sink unchanged. N→M decomposes as Merge → Split — each node stays single-sequence; the pairs Source↔Sink and Merge↔Split also cohere semantically (Transform/Splitter didn't).Renames
Transformtrait →Flow+MergeSqlTransform→SqlMerge;CacheTransform→CacheFlow;AlsTransform→AlsFlow;TopKSimilarityTransform→TopKSimilarityFlowSplittrait + future built-insAlsFactorSplit,RatioSplitPlan
Transform→Flow/Merge, class renames).Splittrait,Plan.Forked, port selector, YAMLas: {port: label}).Pre-release — no published API contract, so the rename is safe in-place.
[-]Add Step DSL (Source/Transform/Sink) for Spark jobs[/-][+]Add Step DSL (Source/Flow/Merge/Split/Sink) for Spark jobs[/+]Add ALS i2i similarity experiment using Step DSL
feat(pipeline): add in-job Step DSL (Source/Transform/Sink) for Spark…
em3s commentedon May 20, 2026
Naming, revisited: keep Flow/Merge/Split, group them under
TransformSuperseding the rename in the previous comment. The arity split itself stands — Flow (1→1) / Merge (N→1) / Split (1→M) remain distinct traits, so both earlier concerns are still met: arity is visible in the type (
SqlTransform extends Merge), and multi-output is expressed bySplit.What changes from the previous plan: instead of making the three siblings of
Source/Sink, a sealed parentTransformis added over them, so the type hierarchy and the package layout both read as the classic three-phase pipeline:Built-ins follow
<function>Transform, with arity carried by the trait they extend:SqlMerge→SqlTransform(extendsMerge)CacheFlow→CacheTransform(extendsFlow)AlsFlow→AlsTransform,TopKSimilarityFlow→TopKSimilarityTransformTrade-off, stated plainly: a built-in's name no longer encodes its arity (you read
SqlTransform, notSqlMerge) — that now lives in the type signature /extendsclause. We take that in exchange for the Source→Transform→Sink symmetry and the type↔package mirror.Landed in #314; #325 rebases onto these names.
feat(pipeline): ALS-based i2i similarity experiment
feat(pipeline): ALS-based i2i similarity experiment
feat(pipeline): ALS-based i2i similarity experiment