Skip to content

Add in-job Step DSL (Source/Transform/Sink) for Spark jobs - #314

Merged
em3s merged 1 commit into
mainfrom
feat/step-dsl-313
May 20, 2026
Merged

em3s merged 1 commit into
mainfrom
feat/step-dsl-313

Conversation

@em3s

@em3s em3s commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Introduces the in-job Step model for Spark jobs. A job is a DAG of steps composed via either a type-state Scala DSL or an inline YAML steps: list interpreted by StepsRunnerJob.

Steps map onto three pipeline phases, with the middle phase split by arity:

  • Source (0→1) — reads data in
  • Transform — the DataFrame→DataFrame middle; a sealed trait with three arities:
    • Flow (1→1) · Merge (N→1) · Split (1→M)
  • Sink (1→0) — writes data out

The Step type hierarchy and the steps.{source,transform,sink} package layout mirror each other one-to-one.

Inner counterpart to the workflow DSL ADR (#310), which covers job-to-job relationships only.

Closes #313

Changes

  • Step sealed hierarchy — Source / Transform (Flow / Merge / Split) / Sink
  • Type-state Plan DSL — ~>, +, .as, fanOut, forked("port")
  • Executor — AST identity memo, fanOut cache/unpersist, Split per-execution memo, plan-time validation
  • StepsRunnerJob + StepsBuilder for inline YAML chains; the builder requires every declared Split port to be labeled
  • ClassResolver — resolves a step by FQN or, failing that, by a memoized recursive scan under a single steps root for a matching simple name (across subpackages, directories, and jar entries); rejects ambiguous simple names
  • Built-ins: FileSource, SampleSource, SqlTransform, CacheTransform, FileSink, ShowSink
  • Tests for each step, builder, and DSL

How to Test

./gradlew :pipeline:test
./gradlew :pipeline:spotlessCheck

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (Opus 4.7, 1M context)

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels May 10, 2026
@em3s
em3s marked this pull request as draft May 10, 2026 14:48
@em3s em3s changed the title Add Step DSL (Source/Transform/Sink) for Spark jobs Add Step DSL (Source/Flow/Merge/Split/Sink) for Spark jobs May 14, 2026
@em3s
em3s marked this pull request as ready for review May 14, 2026 08:21
@em3s
em3s force-pushed the feat/step-dsl-313 branch from 530638b to b55ba09 Compare May 15, 2026 02:12
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. labels May 20, 2026
@em3s em3s changed the title Add Step DSL (Source/Flow/Merge/Split/Sink) for Spark jobs Add in-job Step DSL (Source/Transform/Sink) for Spark jobs May 20, 2026
… jobs

Introduces the in-job Step model: a job is a DAG of steps composed via a
type-state Scala DSL or an inline YAML `steps:` list.

- `Step` sealed hierarchy — Source (0→1) / Transform (Flow 1→1, Merge N→1,
  Split 1→M) / Sink (1→0); the type hierarchy and the steps.{source,
  transform,sink} packages mirror each other.
- Type-state `Plan` DSL — `~>`, `+`, `.as`, `fanOut`, `forked("port")`;
  invalid wiring fails at compile time, the rest at plan time.
- `Executor` — AST identity memo (a shared upstream materializes once),
  fanOut cache/unpersist, per-execution Split memo.
- `PlanValidation` — one structural validator both front-ends reach.
- `StepsRunnerJob` + `StepsBuilder` — build a Plan from YAML; require every
  declared Split port to be labeled.
- `ClassResolver` — resolve a step by FQN or by a memoized recursive scan
  under the single steps root; reject ambiguous simple names.
- Built-ins: FileSource, SampleSource, SqlTransform, CacheTransform,
  FileSink, ShowSink. Tests for each step, the builder, and the DSL.

Inner counterpart to the workflow DSL ADR (#310). Closes #313

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/step-dsl-313 branch from bfd708a to fab948f Compare May 20, 2026 14:21
em3s added a commit that referenced this pull request May 20, 2026
Dogfoods the Step DSL on a real workload: V2 edge JSON →
SqlTransform (prep) → AlsTransform → TopKSimilarityTransform → FileSink.

- AlsTransform (Flow 1→1): wraps spark.ml.recommendation.ALS; emits item
  factors. Implicit-feedback defaults.
- TopKSimilarityTransform (Flow 1→1): cosine-similarity self-join + Window
  top-K, schema (item_id, similar_item_id, score, rank).
- conf/als-i2i-experiment.yaml: production-shape workflow.
- Spark MLlib added to the pipeline module (compileOnly + testImplementation).

Built-ins follow the <function>Transform convention (issue #313); both
extend Flow. Sits on top of the Step DSL (#314).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s

em3s commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

This PR was written largely with AI assistance (Claude Code, Opus 4.7).

It implements the Step model to our requirements (#313): the type-state Plan DSL, the YAML StepsRunnerJob, the memoizing Executor, and the built-in steps, each with tests. CI is green and the change is additive — new pipeline code only, no edits to existing modules.

Merging optimistically; any remaining refinements will be handled in follow-ups.

@em3s
em3s merged commit aba469a into main May 20, 2026
2 checks passed
@em3s
em3s deleted the feat/step-dsl-313 branch May 20, 2026 14:41
em3s added a commit that referenced this pull request May 20, 2026
Dogfoods the Step DSL on a real workload: V2 edge JSON →
SqlTransform (prep) → AlsTransform → TopKSimilarityTransform → FileSink.

- AlsTransform (Flow 1→1): wraps spark.ml.recommendation.ALS; emits item
  factors. Implicit-feedback defaults.
- TopKSimilarityTransform (Flow 1→1): cosine-similarity self-join + Window
  top-K, schema (item_id, similar_item_id, score, rank).
- conf/als-i2i-experiment.yaml: production-shape workflow.
- Spark MLlib added to the pipeline module (compileOnly + testImplementation).

Built-ins follow the <function>Transform convention (issue #313); both
extend Flow. Sits on top of the Step DSL (#314).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
em3s added a commit that referenced this pull request May 20, 2026
Dogfoods the Step DSL on a real workload: V2 edge JSON →
SqlTransform (prep) → AlsTransform → TopKSimilarityTransform → FileSink.

- AlsTransform (Flow 1→1): wraps spark.ml.recommendation.ALS; emits item
  factors. Implicit-feedback defaults.
- TopKSimilarityTransform (Flow 1→1): cosine-similarity self-join + Window
  top-K, schema (item_id, similar_item_id, score, rank).
- conf/als-i2i-experiment.yaml: production-shape workflow.
- Spark MLlib added to the pipeline module (compileOnly + testImplementation).

Built-ins follow the <function>Transform convention (issue #313); both
extend Flow. Sits on top of the Step DSL (#314).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@em3s em3s self-assigned this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Step DSL (Source/Flow/Merge/Split/Sink) for Spark jobs

1 participant